private void buttonlogin_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Stock;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [dbo].[Login] Where Username = '******' and Password = '******'", con); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count == 1) { this.Hide(); StockMain main = new StockMain(); main.Show(); } else { MessageBox.Show("Incorrect Username/Password ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); buttonclear_Click(sender, e); } }
private void button2_Click(object sender, EventArgs e) { // TO-DO: Check Login username & Password SqlConnection con = new SqlConnection("Data Source=LENOVO-PC\\SQLEXPRESS;Initial Catalog=Stock;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [Stock].[dbo].[Login] Where UserName = '******' and Password = '******'", con); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count == 1) { this.Hide(); StockMain main = new StockMain(); main.Show(); } else { MessageBox.Show("Invalid UserName & Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); button1_Click(sender, e); } }