Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SqlConnection sqlCon = new SqlConnection("Data Source=DESKTOP-N2I1H66 ; Initial Catalog=PassBox; Integrated Security=True");
- string sql = "Select * from userInfo where UserName=@u and Password=@p";
- SqlCommand con = new SqlCommand(sql,sqlCon);
- con.Parameters.AddWithValue("@u", txtUsername.Text);
- con.Parameters.AddWithValue("@p",txtPass.Text);
- try
- {
- sqlCon.Open();
- SqlDataAdapter sqda = new SqlDataAdapter(con);
- DataSet dataset = new DataSet();
- sqda.Fill(dataset);
- sqlCon.Close();
- int i = dataset.Tables[0].Rows.Count;
- if (i == 1)
- {
- MainLogin ml = new MainLogin();
- ml.Show();
- ml.Text = "Logged in as : " + txtUsername.Text;
- this.Hide();
- }else
- {
- MessageBox.Show("Login Failed . Check Username & Password");
- txtUsername.Focus();
- }
- }
- catch(Exception couldntconnect)
- {
- MessageBox.Show("Couldn't Connect");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement