[求助]内存非法访问问题
请各位帮我看看这段代码哪里出错了.非常感谢!这是一段删除某个对象的代码,执行删除后,报内存非法访问错:Raised exception class EAccess Violation with Message 'Access violation at address xxxxxx in module '
procedure TFrmMain.ToolButton9Click(Sender: TObject);
var
ii,j:integer ;
deletechart:string;
queryc:TADOQuery;
begin
try
queryc:=TADOQuery.Create(self);
queryc.Connection :=dbprocess.acprocess ;
for ii:=0 to (UntMain.FrmMain.ComponentCount-1) do
begin
if UntMain.FrmMain.Components[ii] is TRectBox then
begin
re:=TRectBox(FrmMain.Components[ii]);
deletechart:=re.Name;
with queryc do
begin
if midstr(deletechart,1,3)='Uob' then /////////////删除活动图信息
begin
uob:=Tuob(FrmMain.Components[ii]);
if uob.Focus then
begin
close;
sql.Clear ;
sql.Text :='select * from uob where uob_id='''+deletechart+'''and model_id='''+model_id+'''';
open;
if recordcount=0 then
begin
combobox1.Items.Delete(combobox1.Items.IndexOf(re.Name));
combobox1.text:='';
VLE.Strings.Clear;
for j:=0 to treeview1.Items.Count-1 do
begin
if treeview1.Items[j].Text=re.Caption then
begin
treeview1.Items.Delete(treeview1.Items[j]);
break;
end;
end;
uob:=nil;
re.Destroy;
break;
end
else
begin
combobox1.Items.Delete(combobox1.Items.IndexOf(re.Name));
combobox1.text:='';
VLE.Strings.Clear;
for j:=0 to treeview1.Items.Count-1 do
begin
if treeview1.Items[j].Text=re.Caption then
begin
treeview1.Items.Delete(treeview1.Items[j]);
break;
end;
end;
with queryc do
begin
close;
sql.Clear ;
sql.Text :='delete * from uob where uob_id='''+deletechart+'''and model_id='''+model_id+'''';
execsql;
end;
uob:=nil;
re.Destroy ;
break;
end;
end;