|
ADO Command 命令的执行 下面的函数实现 Ado Command 命令的执行。 // -------------------------------------------------------------------------------- // 参数: // pAdoCmd: TADOCOMMAND; AdoCommand 组件 // pcExec : string; 命令字符串 // Var pcErrMsg:String ; 变参。命令执行无误时,返回空串。否则保存返回错误信息。 // 返回: // true - 命令被正确执行 // false - 命令执行错误 // 前提: // 为 pAdoCmd 指定连接,并正确连接 // -------------------------------------------------------------------------------- Function ADO_COMMAND_EXEC( pAdoCmd: TADOCOMMAND; pcExec : string; Var pcErrMsg:String ) : boolean ; overload; var Save_Cursor:TCursor; begin pcErrMsg := ''''''''; Save_Cursor := Screen.Cursor; Screen.Cursor := crSQLWait; if trim( pcExec ) = '''''''' then begin Result := False ; pcErrMsg:=''''命令串为空'''';Exit; end; pAdoCmd.CommandText := pcExec ; try pAdoCmd.Execute ; Result := True ; except on E: Exception do begin pcErrMsg := E.Message ; Result := False ; end; end; Screen.Cursor := Save_Cursor ; end; 举例: cCmd := ''''Select Top 1 From Computer''''; if not ADO_COMMAND_EXEC( AdoCmd, cCmd, cError ) then begin ... // 显示错误信息:cError 和 cCmd 语句 end;
( by ForestK )
|