//刚测试完,在delphi 2007上,没问题,可以在FORM1上的GRID上显示出来。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Button1: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TTestThread = class(TThread)
public
FDataSet: TDataSet;
procedure Execute;override;
constructor Create(CreateSuspended: Boolean);
end;
var
Form1: TForm1;
tt: TTestThread;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
tt := TTestThread.Create(False);
end;
{ TTestThread }
constructor TTestThread.Create(CreateSuspended: Boolean);
begin
inherited create(CreateSuspended);
FDataSet := FORM1.ADOQuery1;
end;
procedure TTestThread.Execute;
begin
inherited;
TADOQuery(FDataSet).Close;
TADOQuery(FDataSet).SQL.Clear;
TADOQuery(FDataSet).SQL.Text := 'select * from erpuser.userinfo';
TADOQuery(FDataSet).Open;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
tt.Destroy;
end;
end.