在这里,我尝试将用户ID密码与数据库匹配。
if部分运行正常,而else在浏览器中运行。
代码如下:
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ITD_ClientConnectionString"].ConnectionString);
connection.Open();
string checku = "select count(*) from UserRG where Pan = '" + txtid.Text + "' AND Pass='"+txtpasslog.Text+"' ";
SqlCommand cdm = new SqlCommand(checku, connection);
int temp = Convert.ToInt32(cdm.ExecuteScalar().ToString());
if (temp == 1)
{
Response.Write("<script>alert('hurry ! welcome user')</script>");
}
else { Response.Write("<script>alert('password doesn't match')</script>"); }
答案 0 :(得分:1)
问题必须来自'password doesn't match'
您应该尝试
'password doesn\'t match'
或更可能"password doesn't match"
或找到一种方法来摆脱中间的'