Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnLogIn_Click(object sender, EventArgs e)
- {
- //ekserastikh2016_1_6.Properties.Settings.Database1ConnectionString
- SqlConnection customConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ekserastikh2016_1_6.Properties.Settings.Database1ConnectionString"].ConnectionString);
- customConnection.Open();
- string checkUsername = "select count(*) from [Table] where Username='" + textBox1.Text + "'";
- SqlCommand com = new SqlCommand(checkUsername, customConnection);
- int a = Convert.ToInt32(com.ExecuteScalar().ToString());
- customConnection.Close();
- if (a == 1)
- {
- customConnection.Open();
- string checkPassword = "select Password from [Table] where Username='" + textBox2.Text + "'";
- SqlCommand p = new SqlCommand(checkPassword, customConnection);
- string pass = p.ExecuteScalar().ToString();
- if (pass == textBox2.Text)
- { MessageBox.Show("hello"); }
- else
- { MessageBox.Show("Wrong Username or password"); }
- }
- else
- {
- MessageBox.Show("Wrong Username or password From (If (a==1)else)");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement