qbll = qbll + " from Persons where p_name like '%" + textBox2.Text.Trim() + "%'";
,  你这from前面是不是少空格 ,你这句设个断点,看qb11得到是什么值,就知道哪里错了

解决方案 »

  1.   

     qbll = qbll + " from Persons where p_name like '%" + textBox2.Text.Trim() + "%'";//from前面加个空格
      

  2.   

    select p_id ,p_name ,p_age , p_jig ,p_sex " + checkBox1.Text.Trim(),字段是“p_sex 性别”,当中有空格?
      

  3.   

    var checkboxs = new CheckBox[] { checkBox1, checkBox2, checkBox3, ... }
    var fields = new string[] { "p_sex", "p_shengri", "p_sfzh", ... };
    qbll += ", " + string.Join(", ", checkboxs.Zip(fields, (x, y) => x.Checked ? y : "").Where(x => x != ""));三行代码就能写好的东西你写了快50行。你们老板按照代码行数发工资?