C
coolingxyz
Unregistered / Unconfirmed
GUEST, unregistred user!
//我的一个线程
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 adoqdo
begin
ConnectionString := main.constr;
//这里就出错了,在别的单元里用好的。
close;
sql.Clear;
case PNode.Level of
nlRoot :
begin
sql.Add('Select 命名 From CcName where IP地址 = 0 and 类型 = 1');
Parameters[0].Value := PStrIp(PNode.Data).Ip;
Parameters[1].Value := IpMm;
try
open;
if Not eof then
begin
first;
PNode.Text := Fields[0].AsString;
end;
finally
close;
end;
end;
nlJj :
begin
sql.Add('Select 命名 From CcName where IP地址 = 0 and 机架编号 = 1 and 类型 = 2');
Parameters[0].Value := PStrIp(PNode.Parent.Data).Ip;
Parameters[1].Value := IntToStr(PStrJj(PNode.Data).JjNo);
Parameters[2].Value := JjMm;
try
open;
if Not eof then
begin
first;
PNode.Text := Fields[0].AsString;
end;
finally
close;
end;
end;
nlCc :
begin
sql.Add('Select 命名 From CcName where IP地址 = 0 and 机架编号 = 1 and 插槽编号 = 2 and 类型 = 3');
Parameters[0].Value := PStrIp(PNode.Parent.Parent.Data).Ip;
Parameters[1].Value := IntToStr(PStrJj(PNode.Parent.Data).JjNo);
Parameters[1].Value := IntToStr(PStrCc(PNode.Data).CcNo);
Parameters[3].Value := CcMm;
try
open;
if Not eof then
begin
first;
PNode.Text := Fields[0].AsString;
end;
finally
close;
end;
end;
end;
end;
//with
finally
ADOq.free;
end;
finally
CoUninitialize;
result := True;
end;
end;
编译能通过的。
运行错误是
Project wangguan.exe raised exception class EAccessViolation with message 'Access violation at address 004E44AC in moudule'
Wangguan.exe'.Read of address 000001A0'.Process stopped,use step or run to continue.
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 adoqdo
begin
ConnectionString := main.constr;
//这里就出错了,在别的单元里用好的。
close;
sql.Clear;
case PNode.Level of
nlRoot :
begin
sql.Add('Select 命名 From CcName where IP地址 = 0 and 类型 = 1');
Parameters[0].Value := PStrIp(PNode.Data).Ip;
Parameters[1].Value := IpMm;
try
open;
if Not eof then
begin
first;
PNode.Text := Fields[0].AsString;
end;
finally
close;
end;
end;
nlJj :
begin
sql.Add('Select 命名 From CcName where IP地址 = 0 and 机架编号 = 1 and 类型 = 2');
Parameters[0].Value := PStrIp(PNode.Parent.Data).Ip;
Parameters[1].Value := IntToStr(PStrJj(PNode.Data).JjNo);
Parameters[2].Value := JjMm;
try
open;
if Not eof then
begin
first;
PNode.Text := Fields[0].AsString;
end;
finally
close;
end;
end;
nlCc :
begin
sql.Add('Select 命名 From CcName where IP地址 = 0 and 机架编号 = 1 and 插槽编号 = 2 and 类型 = 3');
Parameters[0].Value := PStrIp(PNode.Parent.Parent.Data).Ip;
Parameters[1].Value := IntToStr(PStrJj(PNode.Parent.Data).JjNo);
Parameters[1].Value := IntToStr(PStrCc(PNode.Data).CcNo);
Parameters[3].Value := CcMm;
try
open;
if Not eof then
begin
first;
PNode.Text := Fields[0].AsString;
end;
finally
close;
end;
end;
end;
end;
//with
finally
ADOq.free;
end;
finally
CoUninitialize;
result := True;
end;
end;
编译能通过的。
运行错误是
Project wangguan.exe raised exception class EAccessViolation with message 'Access violation at address 004E44AC in moudule'
Wangguan.exe'.Read of address 000001A0'.Process stopped,use step or run to continue.