L
lili365
Unregistered / Unconfirmed
GUEST, unregistred user!
有如下代码(将表中的记录显示在TreeView中),但的关闭窗口时却报错:
procedure TForm1.Button1Click(Sender: TObject);
var
TmpSql:string;
begin
If Adoquery1.State<>dsInactive then
Adoquery1.Close;
Adoquery1.SQL.Clear;
TmpSql:='Select * From CardType Where Father is null';
Adoquery1.SQL.Add(TmpSql);
Adoquery1.Open;
Adoquery1.First;
While Not Adoquery1.Eof Do
Begin
new(p);
p^.CardType:=Adoquery1.Fieldvalues['CardType'];
p^.Name:=Adoquery1.Fieldvalues['Name'];
TreeView1.Items.AddObject(nil,p^.Name,p);
Adoquery1.Next;
End;
end;
在执行下面的代码:
procedure TForm1.Button2Click(Sender: TObject);
begin
// FreeAndNil(p);
Adoquery1.Close;
Close;
end;
出现如下的错误:
‘Access violation at 0x6a3bd8b6;read of address 0xfeeefef6’,Process Stopped,Use Stop Orun to continue.
请大侠指点,问题在那里
procedure TForm1.Button1Click(Sender: TObject);
var
TmpSql:string;
begin
If Adoquery1.State<>dsInactive then
Adoquery1.Close;
Adoquery1.SQL.Clear;
TmpSql:='Select * From CardType Where Father is null';
Adoquery1.SQL.Add(TmpSql);
Adoquery1.Open;
Adoquery1.First;
While Not Adoquery1.Eof Do
Begin
new(p);
p^.CardType:=Adoquery1.Fieldvalues['CardType'];
p^.Name:=Adoquery1.Fieldvalues['Name'];
TreeView1.Items.AddObject(nil,p^.Name,p);
Adoquery1.Next;
End;
end;
在执行下面的代码:
procedure TForm1.Button2Click(Sender: TObject);
begin
// FreeAndNil(p);
Adoquery1.Close;
Close;
end;
出现如下的错误:
‘Access violation at 0x6a3bd8b6;read of address 0xfeeefef6’,Process Stopped,Use Stop Orun to continue.
请大侠指点,问题在那里