请问下  这段代码哪出错了啊? 报错是  用户未处理   错误代码是 
      SqlConnection Con = new SqlConnection(SqlDataSource1.ConnectionString);  
string  sel="select * from bbb where user=" + TextBox1.Text; 
SqlCommand addCommand =new SqlCommand(sel,Con);
addCommand.Connection.Open();
SqlDataReader selreader ;
selreader=addCommand.ExecuteReader();//报错
          
                if (selreader.Read())
                {
                    Label3.Text = "登陆成功!";
                    return;
                }                else
                {
                    Label3.Text = "用户名或密码错误~!";
                }

解决方案 »

  1.   

    string  sel="select * from bbb where [user]=" + TextBox1.Text;  将user用[]括起来
      

  2.   

    string  sel="select * from bbb where [user]='" + TextBox1.Text+"'"; 
      

  3.   

    user是字符串类型的,要用单引号
    string  sel="select * from bbb where user='" + TextBox1.Text; 
    sel+="'";
      

  4.   

    string sel = "select * from bbb where [user] = '" + TextBox1.Text + "'"
      

  5.   

    string  sel="select * from bbb where user=" + TextBox1.Text;  
    这个语句要有问题,user是关键字,应该加上[],textbox1.text应该用引号引起来、