dbCommand.CommandText = "select * from table where CLS_ID =  "+a+ ";

解决方案 »

  1.   

    dbCommand.CommandText = "select * from table where CLS_ID =  "+a+ ;最后的+a+要不要引号啊?
    我也学习学习
      

  2.   

    dbCommand.CommandText = "select * from table where CLS_ID =  "+a; 
    不就行了吗
      

  3.   

    --先在前面判断:string a;
    ...
    if (a.trim().tostring()=="")
    {
        a="CLS_ID";
    }这样输入空的时候就查询全部了.
    select * from table where CLS_ID = CLS_ID
    --如果是数字的话:
    select * from table where CLS_ID =  "+a.tostring(); --是字符:
    select * from table where CLS_ID =  " + "'" +a+ "'" ;