I am trying to check info against the table in the database using the data reader , if the condition is met i want to
create a sesion if not o want to redirect the user , but its not working , below is my code ,hope someone can
help me catch up !!!!
conlog.Open();
cmdlogin = new SqlCommand("SELECT password_ ,FirstName,UserName,userid,email,confirmed,Address,Mobile,LastName,Logged from users where UserName = '" + loginname.Text + "'", conlog);
reader = cmdlogin.ExecuteReader();
if (reader[0].ToString() == password.Text && reader[5].ToString() == "True" && reader[9].ToString() != "True")
{
Label1.Text = Convert.ToString(Session["naf"]);
Session["IsAuthenticated"] = true;
reader.Close();
SqlCommand cmdinsert = new SqlCommand("UPDATE users SET Logged='True' WHERE userid=" + Label1.Text, conlog);
cmdinsert.ExecuteNonQuery();
Response.Redirect("DateCheck.aspx");
conlog.Close();
}
else
{
response.redirect("ddd.aspx");
}
conlog.Close();
Dear Prk_in
I know how to retrieve data from the database usind datareader , the thing is why it was working then sudenly stopeedddd any how thank you for your help !
Is it typed correctly "SELECT password_ ,FirstName,UserName ..."?
"password_"
yes in the database the field is password_
the database field Logged , had a datatype of nchar instead of varchar
its working now , thank you for pointing me
沒有留言:
張貼留言