5
Reply

login page

shima

shima

Jul 18 2009 7:47 AM
5.8k

hi
I have problem with login form in c#
I think this problem from if statment
 
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=pjt;Integrated Security=True");
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText =
"SELECT * FROM LOGIN WHERE username='" + tusername.Text +"' AND password=" + tpassword.Text +"'";
SqlDataReader dr =com.ExecuteReader();
if(Convert.ToBoolean(com.CommandText))
{
Menu oform = new Menu();
oform.Show();
}
else
{
MessageBox.Show("username or password incorrect");
}
con.Close();

Answers (5)