Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't trap sql errors using ADO (nested procedures)

Status
Not open for further replies.

koinkoin

Programmer
Jan 5, 2005
6
0
0
US
Hi,

I have the following piece of code which iterates through the potential
errors:
i =0
For Each error_item in myConn.Errors
DTSPackageLog.WriteStringToLog myConn.Errors(i).Description
DTSPackageLog.WriteStringToLog myConn.Errors(i).NativeError
i =i +1
Next

When I execute the procedure using the SQL Query Analyzer, I obtain
several errors in the message window. However, when I execute the
procedure from the ActiveX, nothing is pushed to the log file. In fact
I have even used the following piece of code to count the number of
errors:
DTSPackageLog.WriteStringToLog "myConn.Errors.Count: " &
myConn.Errors.Count
Returns always ZERO.
My procedure are pretty simple, I have the following:

Main procedure:
---------------

while 1 = 1
begin
fetch my_cursor into @count

begin transaction
-- merge the parent issuer into the table issuer

exec @last_error = test_proc @count
if @last_error <> 0 goto handle_error
commit transaction

-- handle the next record
continue

handle_error:
-- error(s), rollback the entire transaction
rollback transaction

test_proc procedure:
--------------------
a simple insert statement, this procedure can generate errors.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top