public List <Combustivel> Listar() { try { AbrirConexao(); var strQuery = "SELECT * FROM Combustivel"; Cmd = new MySqlCommand(strQuery, minhaConexao); Dr = Cmd.ExecuteReader(); List <Combustivel> lista = new List <Combustivel>(); while (Dr.Read()) { Combustivel c = new Combustivel(); c.IdCombustivel = Convert.ToInt32(Dr["IdCombustivel"]); c.Nome = Convert.ToString(Dr["Nome"]).ToUpper(); lista.Add(c); } Dr.Close(); Dr.Dispose(); return(lista); } catch (Exception) { throw; } finally { FecharConexao(); } }
// 返回MySql语句执行结果的第一行第一列 public static string Get_Row1_Col1_Value(string SQL, string ConnStr) { MySqlConnection Conn = Open_Conn(ConnStr); string result; MySqlDataReader Dr; try { Dr = Create_Cmd(SQL, Conn).ExecuteReader(); if (Dr.Read()) { result = Dr[0].ToString(); Dr.Close(); } else { result = ""; Dr.Close(); } } catch { throw new Exception(SQL); } Close_Conn(Conn); return(result); }
private bool CheckAccount(string UserName, string Password) { //SqlDataSource SqlDS = new SqlDataSource(); //SqlDS.ConnectionString = "Data Source=DESKTOP-PIKNVLI\\SQLEXPRESS;Initial Catalog=AMIS_phone;" //+ "User ID=sa; Password =123456" ; // SqlDS.SelectCommandType = SqlDataSourceCommandType.Text; bool boolReturnValue = false; string strConnection = "Data Source=DESKTOP-PIKNVLI\\SQLEXPRESS;Initial Catalog=AMIS_phone;User ID=sa; Password =123456;Integrated Security=True"; SqlConnection sqlConnection = new SqlConnection(strConnection); String SQLQuery = "SELECT Users, Pasword FROM Users where Users='" + UserName + "' and Pasword ='" + Password + "' "; SqlCommand command = new SqlCommand(SQLQuery, sqlConnection); SqlDataReader Dr; sqlConnection.Open(); Dr = command.ExecuteReader(); if (Dr.Read()) { if ((UserName == Dr["Users"].ToString()) & (Password == Dr["Pasword"].ToString())) { boolReturnValue = true; } Dr.Close(); return(boolReturnValue); } return(boolReturnValue); }
protected void Button1_Click(object sender, EventArgs e) //确定修改; { DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo(); //将字符串转化为datetime; dtFormat.ShortDatePattern = "yyyy-MM-dd hh:mm"; DateTime dt1 = Convert.ToDateTime(TextBox5.Text, dtFormat); DateTime dt2 = Convert.ToDateTime(TextBox6.Text, dtFormat); if (TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "" || TextBox5.Text == "" || TextBox6.Text == "") { Response.Write("<script>alert('输入信息不完整,请填写完整航班线信息!')</script>"); } else if (Convert.ToInt32(TextBox2.Text) < 0)//座位数<0; { Response.Write("<script>alert('航班线座位数不可以小于0,请重新输入!')</script>"); } else if (TextBox3.Text == TextBox4.Text)//起飞机场和到达机场相同; { Response.Write("<script>alert('起飞机场和到达机场相同,请重新输入!')</script>"); } else if (dt1 >= dt2)//起飞时间晚于到达时间; { Response.Write("<script>alert('请重新检查起飞和到达时间!')</script>"); } else//可以进行航班线登记; { string strConnection = "Data Source=localhost;Initial Catalog=flight_ticket;Persist Security Info=True;User ID=sa;Password=sql"; SqlConnection Connection = new SqlConnection(strConnection); String strsql = "UPDATE 航班线 SET 起飞机场='" + TextBox3.Text.ToString() + "',到达机场='" + TextBox4.Text.ToString() + "',起飞时间='" + TextBox5.Text.ToString() + "',到达时间='" + TextBox6.Text.ToString() + "',飞行距离='" + TextBox7.Text.ToString() + "',座位数='" + TextBox2.Text.ToString() + "',价格='" + TextBox8.Text.ToString() + "' WHERE 航班号='" + TextBox1.Text.ToString() + "' "; SqlCommand command1 = new SqlCommand(strsql, Connection); string sql = "SELECT * FROM 航班线"; SqlCommand command = new SqlCommand(sql, Connection); SqlDataReader Dr; Connection.Open(); Dr = command.ExecuteReader(); bool boolReturnValue = false; while (Dr.Read())//判断航班线是否有所修改; { if (TextBox2.Text.ToString() == Dr["座位数"].ToString() && TextBox3.Text.ToString() == Dr["起飞机场"].ToString() && TextBox4.Text.ToString() == Dr["到达机场"].ToString() && TextBox5.Text.ToString() == Dr["起飞时间"].ToString() && TextBox6.Text.ToString() == Dr["到达时间"].ToString() && TextBox7.Text.ToString() == Dr["飞行距离"].ToString() && TextBox8.Text.ToString() == Dr["价格"].ToString()) { boolReturnValue = true; } } Dr.Close(); Connection.Close(); if (boolReturnValue == true) { Response.Write("<script>alert('航班线信息没有任何修改,请重新输入!')</script>"); } else { Connection.Open(); command1.ExecuteNonQuery(); Connection.Close(); Response.Write("<script>alert('航班线信息修改成功!');window.location.href ='查询航班线.aspx'</script>"); } } }
} /// /// 返回SQL语句执行结果的第一行第一列 /// /// count(*) public static int ExecuteScalar(string SQL) { SqlConnection Conn; Conn = ReturnConn(); SqlCommand cmd; int result = 0; SqlDataReader Dr; try { cmd = CreateCmd(SQL, Conn); Dr = cmd.ExecuteReader(); if (Dr.Read()) { result = Int32.Parse(Dr[0].ToString()); Dr.Close(); } else { result = 0; Dr.Close(); } } catch { throw new Exception(SQL); } Dispose(Conn); return(result); }
protected void Button3_Click(object sender, EventArgs e) { string username, pwdee; username = TextBox1.Text; pwdee = TextBox2.Text; if (TextBox1.Text == "" || TextBox2.Text == "") { Response.Write("<script lanuage=javascript>alert('帐号或者密码不能为空!!')</script>"); } else { string mySel = "select count(*)as iCount from [admin] where username='******'and pwd='" + pwdee + "'"; OleDbCommand myCmd = new OleDbCommand(mySel, myConn); myCmd.Connection.Open(); OleDbDataReader Dr; Dr = myCmd.ExecuteReader(); Dr.Read(); string Count = Dr["iCount"].ToString();; Dr.Close(); if (Count != "0") { Session["username"] = username; Response.Redirect("centre.aspx"); } else { Response.Write("<script lanuage=javascript>alert('用户名或密码错误!');location='javascript:history.go(-1)'</script>"); } } return; }
private bool MyValidationFunction(string myusername, string mypassword) { bool boolReturnValue = false; string SQLRQST = @"select [No_], Password from [Kingdom Sacco Ltd_$Members Register]"; SqlConnection con = new SqlConnection(strSQLConn); SqlCommand command = new SqlCommand(SQLRQST, con); SqlDataReader Dr; try { con.Open(); Dr = command.ExecuteReader(); while (Dr.Read()) { if ((myusername == Dr["No_"].ToString()) && (mypassword == Dr["Password"].ToString())) { boolReturnValue = true; break; } if (string.IsNullOrWhiteSpace(Dr["Password"].ToString())) { boolReturnValue = false; } } Dr.Close(); } catch (SqlException ex) { SACCOFactory.ShowAlert("Authentication failed!" + ex.Message); } return(boolReturnValue); }
public List <Usuario> Listar() {// lista todos usuarios da base de dados try { var strQuery = "SELECT IdUsuario, Email FROM Usuario WHERE Email <> 'davi' ORDER BY Email ASC"; AbrirConexao(); Cmd = new MySqlCommand(strQuery, minhaConexao); Dr = Cmd.ExecuteReader(); List <Usuario> lista = new List <Usuario>(); while (Dr.Read()) { Usuario usuario = new Usuario(); usuario.IdUsuario = Convert.ToInt32(Dr["IdUsuario"]); usuario.Email = Convert.ToString(Dr["Email"]); lista.Add(usuario); } Dr.Close(); Dr.Dispose(); return(lista); } catch (Exception) { throw; } finally { FecharConexao(); } }
//**************************************************************** public Boolean ConsultaResul(string comando) { //Devuelve un Boolean para indicar si la consulta obtuvo algun resultado Boolean resultado = false; if (m_cnn.State == ConnectionState.Closed) { m_cnn.Open(); } cmd = new SqlCommand(comando, m_cnn); //MessageBox.Show("A connection was successfully established with the server"); Dr = cmd.ExecuteReader(); if (Dr.Read()) { resultado = true; } Dr.Close(); m_cnn.Close(); return(resultado); }
public UsuarioDTO Altenticar(string email, string senha) { try { var strQuery = string.Format("SELECT IdUsuario, Email, Senha FROM Usuario WHERE Email = '{0}' AND Senha = '{1}'", email, senha); AbrirConexao(); Cmd = new MySqlCommand(strQuery, minhaConexao); Dr = Cmd.ExecuteReader(); UsuarioDTO dto = null; if (Dr.Read()) { dto = new UsuarioDTO(); dto.Email = Convert.ToString(Dr["Email"]); dto.IdUsuario = Convert.ToInt32(Dr["IdUsuario"]); } Dr.Close(); Dr.Dispose(); return(dto); } catch (Exception) { throw; } finally { FecharConexao(); } }
public Usuario ListarPorId(int id) {// lista todos usuarios da base de dados try { AbrirConexao(); var strQuery = "SELECT "; strQuery += "IdUsuario, Email "; strQuery += "FROM Usuario "; strQuery += string.Format("WHERE IdUsuario = {0}", id); Cmd = new MySqlCommand(strQuery, minhaConexao); Dr = Cmd.ExecuteReader(); Usuario usuario = new Usuario(); while (Dr.Read()) { usuario.IdUsuario = Convert.ToInt32(Dr["IdUsuario"]); usuario.Email = Convert.ToString(Dr["Email"]); } Dr.Close(); Dr.Dispose(); return(usuario); } catch (Exception) { throw; } finally { FecharConexao(); } }
public bool Existe(string Email) {// verifica se existe antes de alterar senha enviar emaiil etc try { AbrirConexao(); var strQuery = string.Format("SELECT Email FROM Usuario WHERE Email = '{0}'", Email); Cmd = new MySqlCommand(strQuery, minhaConexao); Dr = Cmd.ExecuteReader(); if (Dr.Read()) { Dr.Close(); Dr.Dispose(); return(true); } else { return(false); } } catch (Exception) { throw; } finally { FecharConexao(); } }
/// <summary> /// 返回SQL语句第一列,第ColumnI列, /// </summary> /// <returns>字符串</returns> public string ReturnValue(string SQL, int ColumnI) { string result; SqlDataReader Dr; try { Cmd.CommandText = SQL; Dr = Cmd.ExecuteReader(); } catch { throw new Exception(SQL); } if (Dr.Read()) { result = Dr[ColumnI].ToString(); } else { result = ""; } Dr.Close(); return(result); }
private String YourValidationFunction(string UserName, string Password) { String U_Role = ""; //bool boolReturnValue = false; string SQLQuery = "SELECT EmailAddress, Password, Role FROM User_Details where EmailAddress=@UserName "; SqlConnection sqlConnection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Sri\source\repos\EventsApp\EventsApp\App_Data\EventsAppDB.mdf;Integrated Security=True"); SqlCommand command = new SqlCommand(SQLQuery, sqlConnection); command.Parameters.AddWithValue("@UserName", UserName); SqlDataReader Dr; sqlConnection.Open(); Dr = command.ExecuteReader(); while (Dr.Read()) { if ((UserName == Dr["EmailAddress"].ToString()) & (Password == Dr["Password"].ToString())) { U_Role = Dr["Role"].ToString(); } Dr.Close(); return(U_Role); } return(U_Role); }
protected void Page_Load(object sender, EventArgs e) { //UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; try { string strConnection = WebConfigurationManager.ConnectionStrings["28dayConnectionString"].ConnectionString.ToString(); SqlConnection Connection = new SqlConnection(strConnection); Connection.Open(); String strSQL = "Select * From student where s_sno='" + Session["s_sno"] + "'"; SqlCommand command = new SqlCommand(strSQL, Connection); SqlDataReader Dr; Dr = command.ExecuteReader(); while (Dr.Read()) { Label2.Text = Dr["s_status"].ToString(); } Dr.Close(); Connection.Close(); } catch (Exception ex) { Response.Redirect("~/user_login.aspx"); } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if (YourValidationFunction(Login1.UserName, Login1.Password)) { SqlConnection sqlConnection = new SqlConnection(BopDBLogin.ConnectionString); String SQLQuery = "SELECT * FROM Usuarios where estado = 'Activo' and rtrim(Usuario)='" + Login1.UserName.ToString().Trim() + "'"; SqlCommand command = new SqlCommand(SQLQuery, sqlConnection); SqlDataReader Dr; sqlConnection.Open(); Dr = command.ExecuteReader(); Dr.Read(); String Perfil = Dr["Perfil"].ToString().Trim(); String Usuario = Dr["Usuario"].ToString(); String Nombre = Dr["Nombre"].ToString().Trim(); getMenu(Perfil); Dr.Close(); // UsuarioLogged.Text = Nombre; Global.Perfil = Perfil; Global.Usuario = Usuario; Global.Nombre = Nombre; Login1.Visible = false; } else { e.Authenticated = false; } }
protected void Button7_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["abcConnectionString"].ConnectionString); string s = "select ID,Password,Name from MessManager where ID=" + TextBox1.Text + " and Password="******""; conn.Open(); SqlCommand cmd = new SqlCommand(s, conn); SqlDataReader Dr; Dr = cmd.ExecuteReader(); while (Dr.Read()) { if (TextBox1.Text.ToString() == Dr["ID"].ToString() & TextBox2.Text.ToString() == Dr["Password"].ToString()) { HttpCookie name = new HttpCookie("Name"); name.Value = Dr["Name"].ToString(); Response.Cookies.Add(name); Response.Redirect("~/Staff/staffhome.aspx"); } else { Label1.Text = "Wrong username or passward !!!"; } } Dr.Close(); cmd.Dispose(); conn.Close(); }
private void listBox1_Click(object sender, EventArgs e) { DialogResult dialogResult = MetroFramework.MetroMessageBox.Show(this, "Are you sure you want to delete this Supplier?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { SqlConnection sqlcon = new SqlConnection(Globals_Class.ConnectionString); sqlcon.Open(); string Query = "DELETE FROM SupplierInforamtion WHERE SupplierName='" + listBox1.Text.ToString() + "'"; SqlCommand sqlcom = new SqlCommand(Query, sqlcon); sqlcom.ExecuteNonQuery(); sqlcon.Close(); MetroFramework.MetroMessageBox.Show(this, "Supplier Deleted Successfully!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); listBox1.Items.Clear(); SqlConnection sqlcon1 = new SqlConnection(Globals_Class.ConnectionString); sqlcon1.Open(); string Select = "SELECT SupplierName FROM SupplierInforamtion"; SqlCommand sqlcom1 = new SqlCommand(Select, sqlcon1); SqlDataReader Dr; Dr = sqlcom1.ExecuteReader(); if (Dr.HasRows) { while (Dr.Read()) { listBox1.Items.Add(Dr["SupplierName"].ToString()); } } Dr.Close(); sqlcon1.Close(); txtSearch.Text = ""; } }
public List <Tipo> Listar() {// lista todos usuarios da base de dados try { AbrirConexao(); var strQuery = "SELECT * FROM Tipo"; Cmd = new MySqlCommand(strQuery, minhaConexao); Dr = Cmd.ExecuteReader(); List <Tipo> lista = new List <Tipo>(); while (Dr.Read()) { Tipo tipo = new Tipo(); tipo.IdTipo = Convert.ToInt32(Dr["IdTipo"]); tipo.Nome = Convert.ToString(Dr["Nome"]).ToUpper(); lista.Add(tipo); } Dr.Close(); Dr.Dispose(); return(lista); } catch (Exception) { throw; } finally { FecharConexao(); } }
internal static string[] buscarRegistro(string consultaSQL, string[] columnas) { string[] campos = new string[columnas.Length]; SqlConnection conexion; SqlCommand com; SqlDataReader Dr; Console.WriteLine(consultaSQL); int i = 0; conexion = new SqlConnection(cadenaConexion); com = new SqlCommand(consultaSQL, conexion); conexion.Open(); Dr = com.ExecuteReader(); try { Dr.Read(); foreach (string unaColumna in columnas) { campos[i++] = Dr[unaColumna].ToString(); } } catch (SqlException ex) { ExceptionManager.manejadorExcepcionesSQL(ex); } catch { campos[0] = "vacio"; } conexion.Close(); Dr.Close(); return(campos); }
/// <summary> /// 返回SQL语句执行结果的第一行第一列 /// @auther lyq /// @date 2010.6.18 /// </summary> /// <returns>字符串</returns> public string ReturnValue(string SQL) { SqlConnection Conn; Conn = new SqlConnection(ConnStr); Conn.Open(); string result; SqlDataReader Dr; try { Dr = CreateCmd(SQL, Conn).ExecuteReader(); if (Dr.Read()) { result = Dr[0].ToString(); Dr.Close(); } else { result = ""; Dr.Close(); } } catch { throw new Exception(SQL); } Dispose(Conn); return(result); }
private void Update_a_Supplier_Form_Load(object sender, EventArgs e) { label1.Text = ""; label2.Text = ""; label3.Text = ""; btnUpdate.Enabled = false; listBox1.Items.Clear(); SqlConnection sqlcon1 = new SqlConnection(Globals_Class.ConnectionString); sqlcon1.Open(); string Select = "SELECT SupplierName FROM SupplierInforamtion"; SqlCommand sqlcom1 = new SqlCommand(Select, sqlcon1); SqlDataReader Dr; Dr = sqlcom1.ExecuteReader(); if (Dr.HasRows) { while (Dr.Read()) { listBox1.Items.Add(Dr["SupplierName"].ToString()); } } Dr.Close(); sqlcon1.Close(); }
/// 返回SQL语句第一列,第ColumnI列, /// /// 字符串 public string ReturnValue(string SQL, int ColumnI) { SqlConnection Conn = getSqlConnection(); Conn.Open(); string result; SqlDataReader Dr; try { Dr = CreateCmd(SQL, Conn).ExecuteReader(); } catch { throw new Exception(SQL); } if (Dr.Read()) { result = Dr[ColumnI].ToString(); } else { result = ""; } Dr.Close(); Dispose(Conn); return(result); }
protected void Button1_Click(object sender, EventArgs e) { bool flag = true; string strConnection = WebConfigurationManager.ConnectionStrings["28dayConnectionString"].ConnectionString.ToString(); SqlConnection Connection = new SqlConnection(strConnection); String strSQL = "Select * From student where s_sno='" + TextBox1.Text + "'"; SqlCommand command = new SqlCommand(strSQL, Connection); SqlDataReader Dr; Connection.Open(); Dr = command.ExecuteReader(); while (Dr.Read()) { if (TextBox2.Text == Dr["s_email"].ToString()) { Session["s_sno"] = TextBox1.Text; if (Send()) { Response.Redirect("~/find_pass_prompt.aspx"); flag = false; } } } Dr.Close(); if (flag) { Label3.Text = "账号与邮箱不匹配!"; Label3.Visible = true; } }
public static bool CheckDBState() { SqlConnection Conn; Conn = ReturnConn(); SqlCommand cmd; bool result = false; SqlDataReader Dr; try { cmd = CreateCmd("select getdate()", Conn); Dr = cmd.ExecuteReader(); if (Dr.Read()) { result = true; Dr.Close(); } else { result = false; Dr.Close(); } } catch { throw new Exception("数据库异常~"); } Dispose(Conn); return(result); }
protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e) { ((Login)sender).UserName = ((Login)sender).UserName.ToUpper(); string strConnection = "server=10.0.0.6;database=tiger;user id=jamie;password=jamie;"; SqlConnection sqlConnection = new SqlConnection(strConnection); String SQLQuery = "select count(*) from [tiger].[dbo].[user] where [UserName] like '" + ((Login)sender).UserName + "' and [Password] like '" + ((Login)sender).Password + "'"; SqlCommand command = new SqlCommand(SQLQuery, sqlConnection); SqlDataReader Dr; sqlConnection.Open(); Dr = command.ExecuteReader(); if (Dr.Read()) { if (Convert.ToInt16(Dr[0]) > 0) { e.Authenticated = true; } else { e.Authenticated = false; } } Dr.Close(); if (e.Authenticated) { // write last logged on time SQLQuery = "update [tiger].[dbo].[user] set [TimeLastLoggedIn]='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where [UserName] like '" + ((Login)sender).UserName + "' and [Password] like '" + ((Login)sender).Password + "'"; command.CommandText = SQLQuery; if (1 != command.ExecuteNonQuery()) { throw new Exception("write logged on time failed: " + ((Login)sender).UserName); } } }
protected void Button1_Click(object sender, EventArgs e) { String con = "Server=.;Database=OnlineNoteBook; Integrated Security=true"; SqlConnection connection = new SqlConnection(con); String myquery = "select * from Registration"; SqlCommand cmd = new SqlCommand(myquery, connection); SqlDataReader Dr; connection.Open(); Dr = cmd.ExecuteReader(); while (Dr.Read()) { string email = Dr["Email"].ToString(); string pass = Dr["Password"].ToString(); if (email == TextBoxEmail.Text && pass == TextBoxPassword.Text) { Session["email"] = email; Response.Write("Login successfully"); Response.Redirect("Home.aspx"); } else { Label1.Text = "Invalid Username or Password"; } } Dr.Close(); }
private bool YourValidationFunction(string UserName, string Password) { bool boolReturnValue = false; SqlConnection strConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); string SQLQuery = "SELECT [Name], [Password] FROM [Users]"; SqlCommand cmd = new SqlCommand(SQLQuery, strConnection); SqlDataReader Dr; strConnection.Open(); Dr = cmd.ExecuteReader(); while (Dr.Read()) { string personName = Dr["Name"].ToString(); string personPass = Dr["Password"].ToString(); Label6.Text = UserName + " " + Password; bool name = String.Compare(personName, UserName) == 0; bool pass = String.Compare(personPass, Password) == 0; if (name && pass) { Label6.Text = Dr["Password"].ToString(); boolReturnValue = true; } } Dr.Close(); return(boolReturnValue); }
public courseClass courseInfo(string course, string user) { courseClass response = new courseClass(); SqlConnection con = new SqlConnection(data); SqlCommand cmd = new SqlCommand("SELECT * FROM courseData WHERE courseId = @courseId", con); cmd.Parameters.AddWithValue("@courseId", new Guid(course)); SqlDataReader Dr; con.Open(); Dr = cmd.ExecuteReader(); if (Dr.Read()) { response.courseId = new Guid(Dr["courseId"].ToString()); response.name = Dr["courseName"].ToString(); response.creator = new Guid(Dr["creator"].ToString()); response.company = new Guid(Dr["company"].ToString()); response.created = DateTime.Parse(Dr["created"].ToString()); response.status = Dr["status"].ToString(); response.information = Dr[""].ToString(); response.img = Dr["img"].ToString(); response.price = Convert.ToInt32(Dr["price"]); response.currency = Dr["currency"].ToString(); response.duration = Convert.ToInt32(Dr["duration"]); response.durationUnit = Dr["durationUnit"].ToString(); } Dr.Close(); con.Close(); return(response); }
public bool ValidarHashNovaSenha(string hashNovaSenha) { Abrirconexao(); using (Cmd = new SqlCommand("ValidarHashNovaSenha", Con)) { try { Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue("@hashNovaSenha", hashNovaSenha); Dr = Cmd.ExecuteReader(); if (Dr.HasRows) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception("Erro ao atualizar usuario: " + ex.Message); } finally { Dr.Close(); FecharConexao(); } } }