SqlCommand cmd = new SqlCommand(" select count(*) from users where username = ' "+this.textBoxUserName.Text.ToString()+"  'and password ='  "+this.textBoxUserPassword.Text.ToString()+" ' ",sqlconn);废话不多说,这句话大家应该一看就明白,好像不能完成想要的功能,我认为是单双引号的问题!!

解决方案 »

  1.   

    SqlCommand cmd = new SqlCommand(" select count(*) from users where username = ''"+this.textBoxUserName.Text.ToString()+"''and password =''"+this.textBoxUserPassword.Text.ToString()+"''",sqlconn); 试试这样
      

  2.   

    SqlCommand cmd = new SqlCommand(" select count(*) from users where username = " '+this.textBoxUserName.Text.ToString()+'"and password ="'+this.textBoxUserPassword.Text.ToString()+'"",sqlconn); 
      

  3.   


    SqlCommand cmd = new SqlCommand(" select count(*) from users where username = '"+this.textBoxUserName.Text.ToString()+"' and password ='"+this.textBoxUserPassword.Text.ToString()+"'",sqlconn);