Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 04 SEP 2008 07:02:39AM Martin Drenovac wrote:

Using the ADO libraries to access SQL:

After each OLE I do the usual status=OleStatus()

How do you code the logic to access the description of the error message from the ADODB.Error object? If someone can share the code please? Or, do you utilise a different means to display the error message coming back?

Thank you


At 04 SEP 2008 08:25AM Bob Carten wrote:

Hi Martin,

You might be able to pull the errors out of the connection object.

Below is a code example translated (not tested) from Microsoft.

- Bob

pre.code {

 background-color: #E5E5E5;
 border: 1px solid #000000;
 width: 640px;
 padding: 5px;
 font-family: courier, verdana, arial, serif;
 margin: 0px 10px auto;

}

Function Ado_ErrorList(cn, errorlist)
* Provide information on ADO Errors
*
* See http://msdn.microsoft.com/en-us/library/aa905919(SQL.80).aspx
*

* Parameters
* cn        (in)  the <idispatch> ADO connection object
* ErrorList (out) an fm/vm delimited array of error information

* Loop through each Error object in Errors collection.

Errors=cn->Errors
cnt=Errors->Count
Errorlist='
For i=1 to cnt   
   item=OleGetProperty(Errors, 'Item', i-1)            
   ErrorList<i,1>=Error Number: " : item->Number
   ErrorList<i,2>=  Description: " : item->Description
   ErrorList<i,3>=  Source: " : item->Source
   ErrorList<i,4>=  SQL State: " : item->SQLState
   ErrorList<i,5>=  Native Error: " : item->NativeError            
Next 
           

* Clear the Errors collection.
x=Errors->Clear()

return cnt

At 04 SEP 2008 08:48AM Martin Drenovac wrote:

Cheers Bob - I'll code that up.

Does this mean that your code will give the details of the return value of the OleStatus() number which is returned after an ADO operation?

Thanks again


At 05 SEP 2008 06:31AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

Martin,

You could try using the FormatMessage() Windows API call get more information about the error returned from OleStatus().

The Sprezzatura Group

World leaders in all things RevSoft


At 05 SEP 2008 10:31AM Bob Carten wrote:

Martin -

The code I posted is useful if the OLE objects are healthy but the operation failed, for instance you passed bad SQL an invalid login credentials. Sprezz's posting should help with error messages caused by the OLE objects themselves.


At 28 NOV 2008 08:48AM Chris Leenhouts wrote:

The following Proc should be called with the database connection object after every ADO operation to detect and display any ADO error details;

Compile function SQL_Error(connDB)

declare subroutine msg

eDescription="

if OleStatus() 0 then

 Errors=connDB-]Errors
 eCount=Errors-]Count
 eNumber="
 For ev=1 To eCount
this_error=OLEGetProperty(Errors,"ITEM",ev-1)
    eNumber=this_error-]Number
eDescription=this_error-]DESCRIPTION
 Next ev

end

return eDescription

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/9f89e6f8dc335a3f852574ba003cab37.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1