用ADO实现一个select * from emp的应用

来源:百度知道 编辑:UC知道 时间:2024/09/28 10:22:46
DELPHI数据库考试有可能的一道题!

在窗体中加ADOQuery1,DataSource1,ADOConnection1,DBGrid1还有Button1控件。ADOConnection1中属性ConnectionString连接到你的数据库(选择连接到你的数据库路径),loginprompt属性为false;DBGrid1中属性DataSource为DataSource1;DataSource1控件dataset属性为ADOQuery1;ADOQuery1控件中属性Connection为ADOConnection1

下面是Button中的OnClick事件代码:
procedure TForm1.Button1Click(Sender: TObject);//浏览emp表中的数据
begin

if ADOQuery1.Active then ADOQuery1.Active := False;
ADOQuery1.SQL.Text := 'select * from emp ' ;

ADOQuery1.Open;
end;