Advertisement
Guest User

SQL Login codesPB64

a guest
Nov 14th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. private void btnLogin_Click(object sender, EventArgs e)
  2. {
  3. SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Lenovo\Desktop\Visual Studio labsheet 2nd\ProjectP\ProjectP.mdf;Integrated Security=True");
  4. SqlDataAdapter sqa = new SqlDataAdapter("Select count (*) From tblLogin where Username = '" + txtUser.Text + "' and Password = ' "+ txtPass.Text + "'", con);
  5. DataTable dt = new DataTable();
  6. sqa.Fill(dt);
  7.  
  8. if (dt.Rows[0][0].ToString()=="1")
  9. {
  10. this.Hide();
  11. MainMenu main = new MainMenu();
  12. main.Show();
  13. }
  14. else
  15. {
  16. MessageBox.Show("Username/Password is incorrect. Try again.");
  17. }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement