线程中打开数据连接出错的问题(50分)

  • 主题发起人 主题发起人 ztaif
  • 开始时间 开始时间
Z

ztaif

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls;
type
TConnThread = class(TThread)
Protected
Procedure Execute;
override ;
end;
type
TForm1 = class(TForm)
Button1: TButton;
ADOTable1: TADOTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
ConnThread:TConnThread;
implementation
{$R *.dfm}
{ TConnThread }
procedure TConnThread.Execute;
begin
inherited;
try
Form1.ADOTable1.Open;
except
on E: Exceptiondo
Form1.Memo1.Lines.Add(E.Message);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ConnThread:=TConnThread.Create(False);
end;

end.

出错提示: 尚未调用 CoInitialize。

在那里调用 CoInitialize。 ??????????????
 
uses Activex,ComObj;
try
CoInitialize(nil);
Form1.ADOTable1.Open;
except
on E: Exceptiondo
Form1.Memo1.Lines.Add(E.Message);
end;
UnInitialize;
end;
 
UnInitialize;
这句出错,怎么办?
 
IS 'CoUninitialize' NOT 'UnInitialize'
 
谢谢各位 , 发分拉,呵呵
 
多人接受答案了。
 
后退
顶部