odac 如何捕捉错误odac 如何捕捉错误

Const
  ExecSQLMode = 0 ;
  OpenSQLMode = 1 ;
  ResultRight = ''SQL query result is right'' ;
  ...
  function RunSql(RunQuery: TQuery; Sqls: TStringList; var ErrorMsg: string;
  Mode: integer) : integer ;
  begin
  ErrorMsg := ResultRight ;
  Result := 0 ;
  try
  RunQuery.DatabaseName := ''RecordDB'' ;
  RunQuery.SQL.Clear() ;
  RunQuery.SQL.AddStrings(Sqls) ;
  if Mode = ExecSQLMode then
  RunQuery.ExecSQL()
  else
  RunQuery.Open() ;
  except
  on e:exception do
  ErrorMsg := e.Message + #13 + #10 +''--- 错误是俺发现的 ---'' ;
  end;
  end;

原文地址:https://www.cnblogs.com/hssbsw/p/2298406.html