下面使出错的代码:
    try
      with ADOQuery1 do
        begin
          SQL.Clear;
          SQL.Add('select max(zhh)+1 from jbzh');
          Open;
          zhh:=Fields[0].AsInteger;
          Close;
        end;//执行正常      with ADOQuery1 do
        begin
          SQL.Clear;
          SQL.Add('Insert into jbzh(zhh,sh) values('+IntToStr(zhh) +',''A'')');
          ExecSQL;
        end;//报错,SQL语句是没有错误的!如果把第二个ADOQuery1换成其他的
      ADOQuery就是好的,好像给人感觉是一个ADOQUERY只能执行一遍!
     一下是错误信息:
Debugger Exception Notification
---------------------------
Project XXXX.exe raised exception class EAccessViolation with message 'Access violation at address 1F487CAB in module 'msado15.dll'. Write of address 0122B024'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------
  求助!     

解决方案 »

  1.   

    with ADOQuery1 do
            begin
              SQL.Clear;
              SQL.Add('Insert into jbzh(zhh,sh) values('+IntToStr(zhh) +',''A'')');
              ExecSQL;
            end;//报错,SQL直接用adoconnection执行就可以了:
    adoconnection1.execute('Insert into jbzh(zhh,sh) values('+IntToStr(zhh) +',''A'')');
      

  2.   

    ADOQuery1.close
    ....
    ADOQuer1.open;
      

  3.   

    在SQL.CLEAR前再加一个CLOSE语句
      

  4.   

    ExecSQL语句是返回结果集的,insert插入语句是不带返回结果集的当然回报错了,改成OPEN,就OK了.