//简单一点uses
Classes, SysUtils, Forms, mystruct, Windows, ComCtrls, DB, ADODB, Messages, ActiveX;Function Tmythread.Query(PNode : TTreeNode) : Boolean;
var
adoq : TADOQuery;
begin
try
CoInitialize(nil);
try
with adoq do
begin
ConnectionString := main.constr; //这里就出错了,在别的单元里用好的。错误见下面
close;
sql.Clear;
//其他代码
end;//with
finally
ADOq.free;
end;
finally
CoUninitialize;
result := True;
end;
end;
Classes, SysUtils, Forms, mystruct, Windows, ComCtrls, DB, ADODB, Messages, ActiveX;Function Tmythread.Query(PNode : TTreeNode) : Boolean;
var
adoq : TADOQuery;
begin
try
CoInitialize(nil);
try
with adoq do
begin
ConnectionString := main.constr; //这里就出错了,在别的单元里用好的。错误见下面
close;
sql.Clear;
//其他代码
end;//with
finally
ADOq.free;
end;
finally
CoUninitialize;
result := True;
end;
end;
Tmythread = class(TThread)
private
PFhIp : PStrIp;
constr : String;
rec : Boolean;
protected
procedure Execute; override;
Function Query( PNode: TTreeNode) : Boolean;
Public
constructor Create(TFhIp : TstrIp; Connstr : String; recording : Boolean);
Destructor Destroy; Override;
end;
procedure Tmythread.Execute;
begin
{ Place thread code here }
FreeOnTerminate := True; //线程做完后终止
if not terminated then
Stordata;
end;
Function Tmythread.Query(PNode : TTreeNode) : Boolean;
var
adoq : TADOQuery;
begin
try
CoInitialize(nil);
try
with adoq do
begin
ConnectionString := constr;
Active := False;
sql.Clear;
//其他操作。
end;//with
finally
ADOq.free;
end;
finally
CoUninitialize;
result := True;
end;
end;
ConnectionString := constr; //再下去就出错了