Hi,
I have created a simple login page in c#, the code compiles and runs however it does not execute correctly as when i give the correct input for username and password. it just skips and does the action for the code within the 'else' statement. What am i doing wrong? Could you please help me here. Thanks alot!
System.Data.SqlClient.SqlConnection conn = new SqlConnection("Data Source=ABC-PC;Initial Catalog=EScheduling;Integrated Security=True");
System.Data.SqlClient.SqlCommand cmd = new SqlCommand ("SELECT Username, Password FROM Login_Details where Username = '"+TextBox1.Text.ToString() + "'and Password='"+TextBox7.Text.ToString()+"'", conn);
cmd.Connection = conn;
conn.Open();
System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if ((dr["Username"].ToString() == TextBox1.Text) && (dr["Password"].ToString() == TextBox7.Text))
{
Response.Write("<script>alert('Success')</script>");
Server.Transfer("HomePage.aspx");
}
else
{
Response.Write("<script>alert('You suck')</script>");
TextBox1.Text = " ";
TextBox7.Text = " ";
}
}
}
}