Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 ADO not trapping errors after resultset

Author  Topic 

palloquin
Starting Member

4 Posts

Posted - 2010-09-16 : 07:13:24
Hi all,

I run in to this very annoying behaviour in ADO (used in ASP in this case).
If I run a procedure that is supposed to return a resultsets and the procedure raises an error after the resultset is returned, ADO does not trap the error...

try this code:
SQL:

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


ASP:


dim oConn

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


Anybody find a good way of dealing with this... preferably on the ADO side?

Thanks!

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2010-11-21 : 17:46:38
two things you can do

either add, on error resume next.

or

better yet, what line is the error 16 ???
Go to Top of Page
   

- Advertisement -