private void loginButton_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Despro.mdf;Integrated Security=True"); // making connection SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM dbo.admin WHERE username = '******' AND pass = '******'", con); /* in above line the program is selecting the whole data from table and the matching it with the user name and password provided by user. */ DataTable dt = new DataTable(); //this is creating a virtual table sda.Fill(dt); System.Diagnostics.Debug.WriteLine("username: "******"password: "******"cell 0,0: " + dt.Rows[0][0].ToString()); if (dt.Rows[0][0].ToString() == "1") { SqlDataAdapter sda1 = new SqlDataAdapter("SELECT * FROM dbo.admin WHERE username = '******'", con); /* in above line the program is selecting the whole data from table and the matching it with the user name and password provided by user. */ DataTable dt1 = new DataTable(); //this is creating a virtual table sda1.Fill(dt1); mainMenuSelect mainMenu = new mainMenuSelect(dt1.Rows[0][1].ToString(), dt1.Rows[0][3].ToString()); Hide(); mainMenu.Show(); } else { WrongLabel.Show(); } }
private void UsernameBox_KeyDown(object sender, KeyEventArgs e) { WrongLabel.Hide(); }
public login() { InitializeComponent(); WrongLabel.Hide(); }