需要在添加一个datasource控件,然后adodataset的datasource属性选择datasource1,dbgrid的datasource属性选择datasource1,然后在按钮中写:procedure TForm1.Button1Click(Sender: TObject);
beginADODataSet1.close;
ADODataSet1.CommandText:='select * from 表';
ADODataSet1.Open;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ADODataSet1.CommandText:='select * from my';
ADODataSet1.Open;
end;