qry.Close;
      qry.SQL.Clear;
      qry.SQL.Add('select * from newinv where cCreatePerson='''+trim(edtapply.Text)+'''');
      qry.Open;
      application.MessageBox(PChar(trim(edtapply.Text)+'共有'+inttoStr(qry.RecordCount)   +'条申请记录!'),'提示',mb_ok or mb_iconInformation);
      qry.First;请帮忙看一下吧,看看有没有错。我往文本框里输入人员名点查询,本来数据库中有数据,怎么查不出来。谢谢!

解决方案 »

  1.   

    你用Temp:='select * from newinv where cCreatePerson='''+trim(edtapply.Text)+''''
    检测一下它的值,然后就查询分析器执行,看看行不行就可以了
      

  2.   

    'select * from newinv where cCreatePerson='''+trim(edtapply.Text)+''''建议用like来实现模糊查询。'select * from newinv where cCreatePerson like %'''+trim(edtapply.Text)+'%'''
      

  3.   

    'select * from newinv where cCreatePerson like ''%'+trim(edtapply.Text)+'%'''
      

  4.   

    用like 就可以实现模糊查询了
      

  5.   

    我跟踪了,edtapply.text显示正常的查询数据,执行查询语句后就出问题了。
      

  6.   

    应该是你的建表有问题,你一定是用了char来定义的cCreatePerson,强烈建议改用varchar!就应该会查出结果来了
      

  7.   

    qry.Close;
          qry.SQL.Clear;
          qry.SQL.Add('select * from newinv where cCreatePerson like '''+trim(edtapply.Text)+'''');
          qry.Open;
      

  8.   

    qry.SQL.Add('select * from newinv where cCreatePerson=‘+QuotedStr(tri(edtapply.Text)));
      

  9.   

    哈哈,发现我写错了,谢谢zdyrain(雨)老兄纠正!
      

  10.   

    建议:如果你是用BDE的话,少用qry.RecordCount,因为有时 qry.RecordCount = -1