Forum Moderators: open
I debugged the program and found out that :if(!dread.Read())returns false
why my dread.Read() doesn't work?
please help...
private void login_Click(object sender, System.EventArgs e)
{
string name,email,password;
name=txtname.Text;
email=txtemail.Text;
password=txtpwd.Text;
if(validateUser(name,password))
{.......
}
private bool validateUser(string id, string unHashedpassword)
{
string Connectionstring="Data Source=*******;"uid=*****;"+
"pwd=*****;"+"Initial Catalog=P_Society;";
bool result=false;
string hashedpwd=FormsAuthentication.HashPasswordForStoringInConfigFile(unHashedpassword,"Sha1");
SqlConnection conn=new SqlConnection(Connectionstring);
string sql="SELECT Password FROM DoctorInfo WHERE Name LIKE 'id'";
conn.Open();
SqlCommand cmd=new SqlCommand(sql,conn);
SqlDataReader dread=cmd.ExecuteReader();
if(!(dread.Read()))
result=false;
else
{
if(dread.IsDBNull(0))
result=false;
else
{
result=String.Equals(hashedpwd,dread.GetString((0)));
}
dread.Close();
conn.Close();
}
return result;
}
}
}