例如:
try
      ADOQueryServerDataBaseList.Active :=True;
except    
      RVlue:=MessageBox(FomLogOn.Handle ,'服务器名或IP不正确。','错
      误!',MB_RETRYCANCEL);
      case RVlue of
        0: Exit;
        2: LogOn.FomLogOn.Close ;
        4: EdiServerName.Text :='' ;
      end;
      Exit;
end;    当我输入错误的服务器地址时,程序提示出错,但是运行到
ADOQueryServerDataBaseList.Active :=True;
并不是向下运行到except子句。为什么???????????

解决方案 »

  1.   

    因为你出错的程序代码不是在try块内写的
      

  2.   

    try
          ADOQueryServerDataBaseList.Active :=True;
    except    
          on 错误类 do
              showmessage('服务器名或IP不正确');
          Exit;
    end;    
    错误类你在出错时看看DELPHI的提示,里面有的,要不到网上找找所有异常类的资 料吧...
      

  3.   

    你是不是应该用finally
    不论怎么样,总会执行finally句的内容