偶用了adoquery,datasource,dbgrid,相互之间的设置应该没有问题,(因为我在adoquery的Active设成true的时候,dbgrid中能显示,这是程序不运新的时候)
但是程序运行的时候就不可以了,我怎么样做让程序一运行就显示记录,或者点击按钮显示记录?偶是菜鸟,希望能说的细一点,谢谢!!

解决方案 »

  1.   

    在Form的Create事件中,写如下代码:
    Adoquery1.close;
    Adoquery1.open;
      

  2.   

    在点击按钮事件中输入:
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('查询语句');
    adoquery1.open;
    试试
      

  3.   

    我的语句如下:
    procedure TForm4.BitBtn1Click(Sender: TObject);
    begin          Dm1.ADOQuery1.close;
               Dm1.ADOQuery1.sql.clear;
               Dm1.ADOQuery1.sql.add('select * from MainTab');
               Dm1.ADOQuery1.open;
    end;
    出现的错误代码:
    debugger exception notification
    project project1.exe raised exception class eAccessViolation with message ‘Acess Violation at address 004159b in module ’project1.exe’.Read of........
    不知道是什么错误,帮忙了。