private void button1_Click(object sender, EventArgs e) { this.Close(); mainw frm2 = new mainw(); frm2.Close(); }
private void button2_Click(object sender, EventArgs e) { SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Ayesh Dulanja\Documents\Visual Studio 2015\Projects\WB\userdb.mdf;Integrated Security=True;Connect Timeout=30"); // string query = "Select * from users Where username = '******' and password ='******'"; SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM [users] WHERE username = '******' AND password ='******'", sqlcon); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { mainw mw = new mainw(); this.Hide(); mw.Show(); } else { MessageBox.Show("User Name or Password are Incorrect", "Login Failed"); } txtun.Clear(); txtpw.Clear(); }