OLEDB Returns HResult Error to VB When Using SQL Server 7

OLEDB Returns HResult Error to VB When Using SQL Server 7

Post by Angie Hensle » Wed, 08 Dec 1999 04:00:00



When using either dynamic SQL or a stored procedure with ADO 2.1 in Visual
Basic 6 against a SQL Server 7 database, I am returned a hresult number if
an error occurs.  The error traps correctly, but the Err.Number
reads -2147217900 regardless of the type of error.  The Err.Description
returns useful information, but I need to be able to view the error number
for appropriate action.

Any suggestions?

Thanks.

 
 
 

1. Using FormatMessage() to get HRESULT errors from OLEDB

G'day  Folks,

I've been trying to use FormatMessage() to convert an HRESULT into a
sensible string as per KB article Q169498.

All the HRESULT codes that I'm interested are in the oledberr.h file but do
not appear to be part of the system message table and so the FormatMessage()
api call returns an empty message.

For example the value 0x80040e2f   has the following entry in oledberr.h
which seems to indicate that a message table entry should exist for the
code.

//
// MessageId: DB_E_INTEGRITYVIOLATION
//
// MessageText:
//
//  A specified value violated the integrity constraints for a column or
//  table
//
#define DB_E_INTEGRITYVIOLATION          ((HRESULT)0x80040E2FL)

I've also noticed that the Error Lookup tool supplied with Visual Studio 6.0
cannot find an entry for the errors either.

Anybody know how to turn these codes into error strings?  Do I have to build
my own message table from the entries or something similar?

A reply by email as well as to the group would be appreciated.

Thanks,

Jason.

2. SQL7 upgrade to Win 2000

3. SQL Server Error codes returned to VB

4. how to copy a blank database

5. Problem returning SQL Server Error in VB 6

6. MSSQL range selection !

7. Problem returning SQL Server Error to VB 6

8. logging event through DBlib for C

9. SQL Server Error codes returned to VB

10. Problem returning SQL Server Error to VB 6 with ADO

11. Returning error from SQL Server to VB

12. In SQL Server select statement return error when creating table using ADOX

13. connecting to a remote server using vb+sql server using ADO