Re: Fw: Help with VB & stored procedures
Posted in 1999
mcollins@us.dhl.com wrote: > Apologies in advance if this has been posted previously. I've been trying to post > it to the list over the last week, but have not yet seen it in the emails version of > the group that I get. > > We are trying to execute stored procedures from within a Visual Basic program, and > have managed to actually get the procedure to execute. The problem we have is > that there are several places in the stored procedure that an error can be trapped, > and when we trap one, we raise the -746 error condition and provide a message > detailing what specific error was encountered. The problem we have is that the > programmer can't retrieve the error message within the program. Does anyone have a > code sample that they can share that addresses this problem? > > Thanks in advance. > > > > Mark Collins > mcollins@us.dhl.com Mark, you must provide us with more information about the products : ODBC Provider & Version VB Version Data Access Method (ADO,RDO) and Version In VB6 with ADO 2.0 and CLI 2.5 I have no problem with catching an exception from a SP within a VB programm. It is returned both in the Err Object as in the Errors Collection of the ADODB Connection. All you have to do is to provide an error handling part like for example Dim sqlstr As String Dim rs As adodb.RecordSet On Error Goto Errhandler sqlstr = "EXECUTE PROCEDURE test_sp()" Set rs = ODBCConn.Execute(sqlstr) Exit Sub Errhandler: MsgBox " Error: " & Err & vbCrLf & _ " Description: " & Err.Description End Sub Regards Tolis Varnas -- V+K Relational Solutions mailto:tvarnas@compulink.gr Deligiorgi 26 mailto:tvarnas@orbit.de 546 42 Thessaloniki Voice: +30-31-820270 Greece Fax: +30-31-865463