using system.data;
using System.Data.SqlClient;
using System.Configuration;
using System.Data.SqlClient;
using System.Configuration;
private void btnLogin_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select * from tblogin where username=@u and Password=@p", con);
if (con.State == ConnectionState.Closed)
con.Open();
cmd.Parameters.Add("@u", SqlDbType.VarChar, 50).Value = textBox1.Text;
cmd.Parameters.Add("@p", SqlDbType.VarChar, 50).Value = textBox2.Text;
SqlDataReader dr = cmd.ExecuteReader();
if ((dr.Read() == true))
{
MessageBox.Show("Welcome User");
Form1 obj = new Form1();
obj.Show();
this.Hide();
}
else
MessageBox.Show("Invalid Username and Password");
dr.Close();
}
No comments:
Post a Comment