When there is an Sql error, then the error message is got by SqlGetErrorText( nError, strMessage )
However on some installation strMessage is got and on some it is not got.
What should be done to get this error message on all installations?
TIA
Sqlserver Error Messages
Re: Sqlserver Error Messages
Hi FRBhote,
I've found this in the SqlGetErrorText documentation:
Do you use OLE DB? ... just an idea ...
Regards Michael
I've found this in the SqlGetErrorText documentation:
When connected to an OLE DB data source, do not use this function; use SqlGetSessionErrorInfo instead.
Do you use OLE DB? ... just an idea ...
Regards Michael
Best regards,
Michael Ehehalt
Michael Ehehalt
Re: Sqlserver Error Messages
Unfortunately we use ODBC.
-
- Site Admin
- Posts: 450
- Joined: 05 Mar 2017, 20:57
- Location: Stroud, England <--> Tauranga, New Zealand
Re: Sqlserver Error Messages
.
Have really only ever used OLEDB with SS, but I believe that
'SqlGetErrorText()' returns the error number found in ERROR.sql ( which is SQLBase errors ).
If you only get the error text on some installations - then maybe ERROR.sql is missing from the client ( or the error code is not found in ERROR.sql ).
Maybe try using SqlGetError() in its place, which will turn off error 'mapping' and return the true backend error ( and its actual message Text ).
You can optionally trap only the error codes you want of course.
This is only my theory - as don't use ODBC, but worth a simple try to bypass 'ERROR.sql'
e.g.
Have really only ever used OLEDB with SS, but I believe that
'SqlGetErrorText()' returns the error number found in ERROR.sql ( which is SQLBase errors ).
If you only get the error text on some installations - then maybe ERROR.sql is missing from the client ( or the error code is not found in ERROR.sql ).
Maybe try using SqlGetError() in its place, which will turn off error 'mapping' and return the true backend error ( and its actual message Text ).
You can optionally trap only the error codes you want of course.
This is only my theory - as don't use ODBC, but worth a simple try to bypass 'ERROR.sql'
e.g.
Code: Select all
If SqlGetError( hpSqlHandle, nError, sTemp )
If TcsIsSqlServer( hpSqlHandle )
Loop
Set nChar = SalStrLop( sTemp )
If Not nChar
Break
Set sError = sError || SalNumberToChar( nChar )
!
Set sError = VisStrSubstitute( sError, '[Microsoft][ODBC SQL Server Driver][SQL Server]', ' - ' )
!
Select Case nError
Case 20030
If SalStrScan( sError, '2601' ) > -1
Set nError = SqlErr_UniqueDataRequired
Else If SalStrScan( sError, '2627' ) > -1
Set nError = SqlErr_UniqueDataRequired
Else
Set nError = SqlErr_UnmatchedForeignKey
Break
Case 20050
Set nError = SqlErr_TableNotCreated
Break
Case 20054
Set nError = SqlErr_InvalidColumnName
Break
Default
! Do nothing as we don't recognise the error
!
Set srpError = sError
Else
Set srpError = sTemp
Set nrpError = nError
Return TRUE
Return FALSE
Greetings from New Zealand
Steve Leighton
Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand
www.banksidesystems.co.uk

Steve Leighton
Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand
www.banksidesystems.co.uk

Who is online
Users browsing this forum: [Ccbot] and 12 guests