有如下sql语句,用strsql:='select * from 表1 where id like ''G%''';
查询开头为G的代码,但adoQuery1.RecordCount为0,这是什么原因,我用的是access

解决方案 »

  1.   

    adoQuery1.Open了吗?
    access支持like吗?
      

  2.   

    strsql:='select * from 表1 where [id] like ' + QuotedStr('G%');
      

  3.   

    var
    m_count:integer;
    begin
    with query do
      close;
      sql.clear; 
      sql.add('select count(*) from TABLE1 where [id] like ''G%''');
      open;
      if fields[0].asinteger<>0 then
          begin
             close;
             sql.clear;
             sql.add('select * from TABLE1 where [id] like ''G%''');
             open;
          end
       else
          begin
            showmessage('No records ');
          end;//if
     end//with这样可以解决
    因为DELPHI的ADO有一些缺陷。 recordcount不一定获得你所要的值。
    自己查询一下比较好希望能解决你的问题。
      

  4.   

    strsql:='select * from 表1 where id like '''G%'''';