C
coolingxyz
Unregistered / Unconfirmed
GUEST, unregistred user!
unit search;
interface
uses
Classes, ComCtrls, ADODB, Dialogs;
type
TSearch = class(TThread)
private
{ Private declarations }
SearchName : String;
protected
procedure Execute;
override;
Public
constructor Create(ccName : String);
Destructor Destroy;
Override;
end;
implementation
uses main;
constructor TSearch.Create(ccName : String);
begin
SearchName := ccName;
inherited Create(False);
end;
procedure TSearch.Execute;
Var
RootNode, JjNode : TTreeNode;
i : Integer;
ADOQuery1 : TADOQuery;
IpStr, Port, Jjid, ccid : String;
begin
FreeOnTerminate := True;
//线程做完后终止
ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+
main.MyPath +'db/fhwg.mdb;Jet OLEDBatabase Password='+''
+';Persist Security Info=False';
//编译能通过,但是运行的时候出错。错误见下面。
With ADOQuery1do
begin
sql.Clear;
sql.Add('Select * From ccName where 命名 = ' + SearchName);
try
open;
except
MessageDlg( '打开数据库出错!', mtError, [mbOK], 0 );
exit;
end;
if Not Eof and Not Bof then
begin
IpStr := Fields[1].AsString;
Port := Fields[2].AsString;
Jjid := Fields[3].AsString;
ccid := Fields[4].AsString;
end else
begin
MessageDlg( '没有这条记录!请确定你是否输入正确。', mtError, [mbOK], 0 );
exit;
end;
end;
// RootNode := Main.FrmFh.TvwFh.Items.GetFirstNode;
// For
end;
Destructor TSearch.Destroy;
begin
SearchName := '';
inherited Destroy;
end;
end.
运行时出错提示是:“Project wangguan.exe raised exception class EAccessViolation with
message 'Access violation at address 004E45DA in moudule 'wangguan.exe'.Read of address
00000038 '. Process stopped. Use Step or Run to continue.”。
我在其他窗体里这么用ADOQuery是可以用的。线程里为什么出错呀?
interface
uses
Classes, ComCtrls, ADODB, Dialogs;
type
TSearch = class(TThread)
private
{ Private declarations }
SearchName : String;
protected
procedure Execute;
override;
Public
constructor Create(ccName : String);
Destructor Destroy;
Override;
end;
implementation
uses main;
constructor TSearch.Create(ccName : String);
begin
SearchName := ccName;
inherited Create(False);
end;
procedure TSearch.Execute;
Var
RootNode, JjNode : TTreeNode;
i : Integer;
ADOQuery1 : TADOQuery;
IpStr, Port, Jjid, ccid : String;
begin
FreeOnTerminate := True;
//线程做完后终止
ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+
main.MyPath +'db/fhwg.mdb;Jet OLEDBatabase Password='+''
+';Persist Security Info=False';
//编译能通过,但是运行的时候出错。错误见下面。
With ADOQuery1do
begin
sql.Clear;
sql.Add('Select * From ccName where 命名 = ' + SearchName);
try
open;
except
MessageDlg( '打开数据库出错!', mtError, [mbOK], 0 );
exit;
end;
if Not Eof and Not Bof then
begin
IpStr := Fields[1].AsString;
Port := Fields[2].AsString;
Jjid := Fields[3].AsString;
ccid := Fields[4].AsString;
end else
begin
MessageDlg( '没有这条记录!请确定你是否输入正确。', mtError, [mbOK], 0 );
exit;
end;
end;
// RootNode := Main.FrmFh.TvwFh.Items.GetFirstNode;
// For
end;
Destructor TSearch.Destroy;
begin
SearchName := '';
inherited Destroy;
end;
end.
运行时出错提示是:“Project wangguan.exe raised exception class EAccessViolation with
message 'Access violation at address 004E45DA in moudule 'wangguan.exe'.Read of address
00000038 '. Process stopped. Use Step or Run to continue.”。
我在其他窗体里这么用ADOQuery是可以用的。线程里为什么出错呀?