错误如下:
Access violation at address 0049ADC2 in module 'Sys_pro.exe'. Read of address 00000000源码如下:
procedure TSys_GroupUser.lvGroupClick(Sender: TObject);
var
j:word;
begin
showgroupbid.Caption :=lvGroup.Selected.SubItems[1];
showgroupname.Caption :=lvGroup.Selected.SubItems[0];
Gbuser.Caption :='【'+lvGroup.selected.SubItems[0]+'】'+'所拥有的用户' ;
try
     with Sys_DBM.AddUserToGroup do
      begin
       close;  //在这里出错
       SQL.Clear ;
       SQL.Text :='Select UserName from Sys_GroupUser where GroupID=:GroupID';       Parameters.ParamByName('GroupID').Value :=trim(showgroupbid.Caption);
       open;
       if IsEmpty then exit;
       first;
       for j:=0 to RecordCount-1 do
        begin
         lvUser.Items.Add.Caption :=fieldbyname('UserName').AsString ;
         next;
        end;
       close;
       free;
      end;
except
  on E:exception do
   begin
     application.MessageBox(Pchar('遇到错误'+#10#13+E.message),'严重错误!',MB_OK+MB_ICONERROR);
     exit;
   end;
end;
end;

解决方案 »

  1.   

    close;  //在这里出错
    改成 
    if Active then
      Active:=False;
    试试
      

  2.   

    Sys_DBM.AddUserToGroup
    Access violation at address 0049ADC2 in module 'Sys_pro.exe'. Read of address 00000000
    应该是访问了一个未实例化的对象
    确保AddUserToGroup已经被正常创建
      

  3.   

    经过调试...AddUserToGroup被正常创建....
      

  4.   

    搞定....去掉.free就OK了...谢谢各位了