Advertisement
Guest User

Untitled

a guest
Oct 4th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. private void methodConfirmation()
  2.         {
  3.             try
  4.             {
  5.                 connection.Open();
  6.                 command.Connection = connection;
  7.                 string sqlConfirm = "SELECT userName, password FROM tblUser WHERE userName = @username AND password = @password";
  8.                 command.CommandText = sqlConfirm;
  9.                 command.Parameters.AddWithValue("@username", username);
  10.                 command.Parameters.AddWithValue("@password", txtPassword.Text);
  11.                 SqlDataReader reader = command.ExecuteReader();
  12.                 command.Parameters.Clear();
  13.                 if (reader.HasRows)
  14.                 {
  15.                     connection.Close();
  16.                     successful = "true";
  17.                     this.Tag = successful;
  18.                     this.Close();
  19.                 }
  20.                 else
  21.                 {
  22.                     MessageBox.Show("Incorrect password.");
  23.                     txtPassword.Focus();
  24.                 }
  25.             }
  26.             catch (Exception ex)
  27.             {
  28.                 MessageBox.Show("Error: " + ex);
  29.             }
  30.             finally
  31.             {
  32.                 connection.Close();
  33.             }
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement