Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btn_login_Click(object sender, EventArgs e)
- {
- string conn = ("datasource=localhost;Initial Catalog='MyDb';username=root;password=blahblah");
- MySqlConnection con = new MySqlConnection(conn);
- MySqlCommand cmd = new MySqlCommand("select * from employees where BINARY usr_name=@name And BINARY usr_pwd=@pass", con);
- cmd.Parameters.AddWithValue("@name", txtUser.Text);
- cmd.Parameters.AddWithValue("@pass", txtPass.Text);
- con.Open();
- MySqlDataAdapter adpt = new MySqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- adpt.Fill(ds);
- con.Close();
- if (ds.Tables[0].Rows.Count > 0)
- {
- MessageBox.Show(" Login Successful.nn Welcome back " + txtUser.Text + "!");
- }
- else
- {
- MessageBox.Show(txtUser.Text + ", you entered an invalid username and/or password!nnPlease try again...");
- }
- }
Add Comment
Please, Sign In to add comment