登陆界面的用户名密码验证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> ");

解决方案 »

  1.   

    & ==>  &&
      

  2.   

    &&也不行啊。提示:运算符“&”无法应用于“bool”和“string”类型的操作数
      

  3.   

    并且是&&或者是||不是你写的一个&
      

  4.   

    bool怎么和string比啊 不能比
      

  5.   

    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() )
      

  6.   

    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() )  把你的&和and 全部换成&&就行了.
      

  7.   

    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())
    {
    }
    }   
      

  8.   

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

  9.   

    Login1.UserName == ds.Tables["t1"].Rows[0]
      

  10.   

    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() )   
    注意是'==',不是'='或者 'and'
      

  11.   

    =是赋值,==才是比较...和&或&&毫无关系,“and”更是胡闹...这是C#,不是VB
      

  12.   

    &运算符可以的。能够实现&&的功能.
      

  13.   

    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() )   
      

  14.   

    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() )   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()里面不能是= 应该是==   并且的话 就是&& 
      

  15.   

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