本帖最后由 tuzhenyuan1990 于 2013-05-22 15:46:45 编辑

解决方案 »

  1.   

    什么都没有,你问谁啊,自己把sql放到数据库中查去
      

  2.   

    NO  NO  NO  这个是执行以后的效果图。我之前是有数据的。
      

  3.   

    文本框是空的,什么也查不到!!!!!!!我刚试了呢!!!!!!!
    把AND 改OR  
      

  4.   

    string sqlquery = "select * from Person where psnNo LIKE'%"
                                + tbContent.Text + "%'and psnName LIKE'%"
                                + tbContent.Text + "%' and psnSex LIKE'%"
                                + tbContent.Text + "%' and psnAge LIKE'%"
                                + tbContent.Text + "%' and psnAddress LIKE'%"
                                + tbContent.Text + "%'and psnDuty LIKE'%"
                                + tbContent.Text + "%'";
    有问题吧,你试下,如果 tbContent.Text="0001"那么,sqlquery=
    select * from Person where psnNo LIKE '%0001%' and psnName like '%0001%' and psnSex like '%0001%'...
      

  5.   

    我觉得你是不是想这样表达吧,假如查询类型选择的控件是 dlType
    string sqlquery = "select * from Person";
    if (dlType.Text =="学号")
    {
    sqlquery +=" where psnNo LIKE '%"  + tbContent.Text + "%'"; 
    }
    else if (dlType.Text =="姓名")
    {
    sqlquery +=" where psnName LIKE '%"  + tbContent.Text + "%'"; 
    }
    ...
      

  6.   


    如果是精确查找的时候,如果输入一个“果”字,为什么出现这个错误提示“在将 varchar 值 '果' 转换成数据类型 smallint 时失败。”???/
      

  7.   

    文本框是空的,什么也查不到!!!!!!!我刚试了呢!!!!!!!
    把AND 改OR  如果是精确查找的时候,如果输入一个“果”字,为什么出现这个错误提示“在将 varchar 值 '果' 转换成数据类型 smallint 时失败。”??????
      

  8.   


    如果是精确查找的时候,如果输入一个“果”字,为什么出现这个错误提示“在将 varchar 值 '果' 转换成数据类型 smallint 时失败。”???/用这个方法应该就不会了
      

  9.   


    如果是精确查找的时候,如果输入一个“果”字,为什么出现这个错误提示“在将 varchar 值 '果' 转换成数据类型 smallint 时失败。”???/用这个方法应该就不会了,但如查是数字型的字段要变一下如年龄:
    if (dlType.Text =="学号")
    {
    sqlquery +=" where psnNo LIKE '%"  + tbContent.Text + "%'"; 
    }
    else if (dlType.Text =="姓名")
    {
    sqlquery +=" where psnName LIKE '%"  + tbContent.Text + "%'"; 
    }
    else if (dlType.Text =="年龄")
    {
    sqlquery +=" where psnAge ="  + tbContent.Text; 
    }