write the sql statement out and run the query manually in SQL Query Analyzer to make sure it returns anythingString SelCmd="select [userinfo].username,[userinfo].password from [userinfo]";
SelCmd+="where [userinfo].username='%"+loginbox.Text+"%' and [userinfo].password='%"+passwordbox.Text+"%'";Response.Write("****" + SelCmd + "***");by the way, you should be doing something likeSqlConnection cnn=new SqlConnection("server=paradise;uid=sa;pwd=;database=book");
String SelCmd="select count(*) from userinfo where username = '"+loginbox.Text +"' and password='"+passwordbox.Text+"'";
SqlCommand myComm=new SqlCommand(SelCmd,cnn);
cnn.Open();
int nCount = (int)myComm.ExecuteScalar();
cnn.Close(); if (nCount > 0)
{
Session["logok"]="-1";
loginlb.Text="welcom.you have logined";
Session["userid"]="tom";
serchbtn.Visible=true;
}
else
{
Response.Redirect("http://localhost/hs/error.aspx");
}