首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

运算符“&”没法应用于“bool”和“string”类型的操作数

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

运算符“&”无法应用于“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() )

热点排行