private void button2_Click(object sender, EventArgs e) { this.Hide(); StockMain main = new StockMain(); main.Show(); }
private void button2_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDb)\LocalDBDemo;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("Invalid Username or Password !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); button1_Click(sender, e); } }