I'm using SQLSErver6.0 with VB4/16 & ODBC. (DAO level)
Can anyone tell me how to trap the error Number generated by SQLServer
if a call fails (Eg: Attempt to insert null into a column that does not
allow null)
It returns: "ODBC Call failed, Error 3146".
I would like it to return : "Msg 515, Level 16, State 3
Attempt to insert the value NULL into column 'C1', table
'StaffDev.dbo.frdTest'; column does not allow nulls. INSERT fails.
Command has been aborted." or at least just the error & State Number
--
Frédéric.
--
Karl Costenbader, President
Competent Consulting
Sacramento, CA
EMail: ka...@competent.com
Home Page: http://www.competent.com
U can indeed get the complete message displayed as follows:
Use DBEngine.Errors(0).Number to display the actual error number...and
use DBEngine.Errors(0).Description to display the actual message.
This we are using and is working fine.
Bye,
Maruthi.
If you're using DAO, loop thru the DBEngine.Errors collection -- it
has the details of the errors. (DBEngine.Errors(0) has the 3146
error, but .Errors(1) thru (n) has the more detailed stuff.)
>Sajal Kumar <saj...@clientlink.com> writes: > Boistuaud Frederic wrote:
>> >
>> > Hi folks,
>> >
>> > I'm using SQLSErver6.0 with VB4/16 & ODBC. (DAO level)
>> >
>> > Can anyone tell me how to trap the error Number generated by SQLServer
>> > if a call fails (Eg: Attempt to insert null into a column that does not
>> > allow null)
>> > It returns: "ODBC Call failed, Error 3146".
>> > I would like it to return : "Msg 515, Level 16, State 3
>> > Attempt to insert the value NULL into column 'C1', table
>> > 'StaffDev.dbo.frdTest'; column does not allow nulls. INSERT fails.
>> > Command has been aborted." or at least just the error & State Number
>> >
>> > --
>> > Frédéric.
>> i am surprised that you are only getting the first message that ODBC
>> call failed and not the Msg 515.... part. vb3 use to return ODBC call
>> failed message along with the one spit out by the server.
>> thanx.
>> sajal.
>U can indeed get the complete message displayed as follows:
>Use DBEngine.Errors(0).Number to display the actual error number...and
>use DBEngine.Errors(0).Description to display the actual message.
>This we are using and is working fine.
>Bye,
>Maruthi.
Dim objErr as Error
Dim strMsg as String
Dim intErr as Long
For Each objErr in Errors
strMsg = strMsg & "<" & CStr(objErr.Number) & ">"
strMsg = strMsg & objErr.Description & vbCrLf
Next
intErr = Err.Number
Err.Raise intErr, , strMsg
This will return one messagebox with a header of Error: 3146
followed by each ODBC error number and description with a linefeed
between error listed. Useful in ole server situation.
Steve Daniels ste...@ptdprolog.net