【发布时间】:2013-05-07 10:52:40
【问题描述】:
while (reader.Read())
{
if (TextBox1.Text.CompareTo(reader["usernam"].ToString()) == 0&&TextBox2.Text.CompareTo(reader["passwd"].ToString()) == 0) // A little messy but does the job to compare your infos assuming your using a textbox for username and password
{
Label3.Text = "Redirecting";
Response.Cookies["dbname"]["Name"] = reader["usernam"].ToString();
Response.Cookies["dbname"].Expires = DateTime.Now.AddSeconds(10);
Response.Redirect("index2.aspx");
}
else
{ Label3.Text = "NO"; }
}
当我尝试比较用户名 (usernam) 和密码 (passwd) 时,我收到此错误。 如果我只将用户名与数据库条目进行比较,它就像一个魅力。
只有在使用实际数据时才会报错。 EI如果我在登录网页中输入 [admin], [admin] 它会给我错误,如果我输入 [asd], [asd] 那么标签将变为 NO。
代码背后的想法是一个登录页面。 我希望我的解释足够好。
【问题讨论】:
-
请将实际代码添加到您的问题中作为文本。
标签: c# asp.net vb.net ms-access