Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- if (!(Username_Text.Text == string.Empty))
- {
- if (!(Password_Text.Text == string.Empty))
- {
- SqlConnection connection = new SqlConnection("Data Source=ICSD-DB\\ICSDMSSQLSRV;Initial Catalog=icsd14063;Integrated Security=True");
- String sqlString = "select * from RegisterUsers where username = '" + Username_Text.Text + "'and pass = '" + GetStringSha256Hash(Password_Text.Text) + "'";
- connection.Open();
- SqlCommand command = new SqlCommand(sqlString, connection);
- SqlDataReader dbr;
- dbr = command.ExecuteReader();
- int count = 0;
- while (dbr.Read())
- {
- count = count + 1;
- }
- if (count == 1)
- {
- MessageBox.Text = ("Username and password is correct.");
- Session["Set_Visible"] = "true";
- Response.Redirect("Home.aspx?number1=" + Username_Text.Text);
- }
- else if (count > 1)
- {
- MessageBox.Text = ("Username and password incorrect.");
- }
- else
- {
- MessageBox.Text = ("Username and password incorrect.");
- }
- }
- else
- {
- MessageBox.Text = ("Password empty.");
- }
- }
- else
- {
- MessageBox.Text = ("Username empty.");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Text = ex.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement