ADO not receiving errors raised in sub procedure

95 pts.
Tags:
ActiveX
ActiveX Data Objects
ADO
ASP
SQL Server 2008
Stored Procedures
VBScript
Hi,
I'v known for a while that ado has it's limits when it comes to dealing with errors... but this one hurts:
I have a StoredProcedure (SP) that calls a sub procedure.
In the sub procedure an error is raised.
The error does not reach ADO for some reason.
After some research I find that if the sub procedure returns a result set before it raises the error this problem occurs, else, the error reaches ADO just fine.
Example code:
main procedure:
CREATE PROCEDURE sp_test
AS
EXEC sp_error
sub  procedure:
CREATE PROCEDURE [dbo].[sp_error]
AS
/* IF THIS LINE IS HERE, ERROR DO NOT SHOW UP IN ADO */
SELECT 'test' AS value
RAISERROR ('this is an error', 16, 1)
RETURN
VBSCript (ASP) code:
dim oConn, oRS
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.ConnectionString = ConnString
oConn.CommandTimeout = 180
oConn.Open 
Set oRS = Server.CreateObject("ADODB.recordset")
oRS.activeconnection = oConn
oRS.cursortype = 3
oRS.locktype = 4
oRS.CursorLocation = 3
oRS.source = "EXEC test.dbo.sp_error"
oRS.open
oRS.close
oConn.close
SET oRS = Nothing
SET oConn = Nothing
Now, I understand that I could work around this, by testing for the error in the main procedure etc... BUT THIS SHOULD JUST WORK!!!
Any thoughts?


Software/Hardware used:
SQL Server 2008, ADO,
ASKED: August 31, 2010  11:42 AM
UPDATED: September 16, 2010  11:05 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Palloquin
    It seems to be slightly different... Is I generate any resultsets before the error is raised, ADO does not seem to trap it. I do not need sub procedures for this, even this code works:
    CREATE  PROCEDURE [dbo].[sp_error]
    AS
    	/* IF THIS LINE IS HERE, ERROR DO NOT SHOW UP IN ADO */
    	SELECT 'test' AS value
    
    	RAISERROR ('this is an error', 16, 1)
    	RETURN
    
    
    95 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following