hi, i m trying to make something like a login page and i used the following code to compare the Users password from a password text box and then compare it with the Database password to see if it is the same. nevertheless when i compare the strings the system doesnt accept them as the same and i cant login.(i also tried the String.Compare but i get the same resuly). Any help pleasE?
String username = txtusername.Text;
String password = txtpass.Text;
String connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "select password from Details WHERE username='" + username + "';";
Console.WriteLine(cmd.CommandText);
conn.Open();
String pass = cmd.ExecuteScalar().ToString();
conn.Close();
if (pass==password)
{
Label1.Text = "Y";
}
else
{
Label1.Text="N";
}