读书人

运算符“amp;”没法应用于“bool”和“st

发布时间: 2012-10-17 10:25:47 作者: rapoo

运算符“&”无法应用于“bool”和“string”类型的操作数
登陆界面的用户名密码验证

CS0019: 运算符“&”无法应用于“bool”和“string”类型的操作数
用and好像也不行?


if (ds.Tables["t1"].Rows.Count ==1 & Login1.UserName = ds.Tables["t1"].Rows[0]["t1_username"].ToString() and Login1.Password = ds.Tables["t1"].Rows[0]["t1_pwd"].ToString() )

{
Response.Write("登陆成功!");

}
else
{
this.ClientScript.RegisterStartupScript(this.GetType(), "alter", "<script>alert(\"请检查用户名或密码\");</script> ");

[解决办法]
if (ds.Tables["t1"].Rows.Count>0)//先判断数据有没有在判断密码用户名是否匹配比较好
{
if( Login1.UserName = ds.Tables["t1"].Rows[0]["t1_username"].ToString() && Login1.Password = ds.Tables["t1"].Rows[0]["t1_pwd"].ToString())
{
}
}


[解决办法]
开始只看了第一个,后面也要改:
if (ds.Tables["t1"].Rows.Count ==1 && Login1.UserName == ds.Tables["t1"].Rows[0]["t1_username"].ToString() && Login1.Password == ds.Tables["t1"].Rows[0]["t1_pwd"].ToString() )
[解决办法]

C# code
if (ds.Tables["t1"].Rows.Count ==1 && Login1.UserName == ds.Tables["t1"].Rows[0]["t1_username"].ToString() && Login1.Password == ds.Tables["t1"].Rows[0]["t1_pwd"].ToString() )
[解决办法]
if (ds.Tables["t1"].Rows.Count ==1 && Login1.UserName == ds.Tables["t1"].Rows[0]["t1_username"].ToString() && Login1.Password == ds.Tables["t1"].Rows[0]["t1_pwd"].ToString() )

读书人网 >C#

热点推荐