Re: Stored Procedure returning a closed recordset
From: William \(Bill\) Vaughn (billvaRemoveThis_at_nwlink.com)
Date: 02/11/05
- Next message: William \(Bill\) Vaughn: "Re: Updating/Inserting rows in SQL Server 2000 with text data types"
- Previous message: Brendan Reynolds: "Re: SQL server data into Word?"
- In reply to: kaldvelski_at_yahoo.co.uk: "Stored Procedure returning a closed recordset"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 11 Feb 2005 04:04:52 -0800
This behavior is by design. Each TSQL operation creates a resultset. ADO
processes these resultsets one-at-a-time. Those that contain rowsets (the
result of a SELECT) cause the State flag to be set to adStateOpen--those
that don't State is set to adStateClosed (as you're seeing). You have at
least two choices when processing resultsets returned from stored
procedures:
1) Add SET NOCOUNT ON to eliminate all non-rowset resultsets. This
throws away the number of rows affected by the action command (INSERT etc.).
2) Step through the resultsets with the NextRecordset method until the
returned Recordset is Nothing.
More details and examples? Check out my ADO Examples and Best Practices
book.
hth
-- ____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ <kaldvelski@yahoo.co.uk> wrote in message news:1108121156.510676.97220@f14g2000cwb.googlegroups.com... > I'm executing a stored procedure (on SQL server) that should return a > series of records. However, I'm getting a closed recordset as if ADO > doesn't think the sproc returns any records - when it should be. > > After stripping the sproc down I discovered that if the sproc is a > simple SELECT then it returns fine but if I perform an INSERT before > the SELECT then I get nothing back. Executing the stored procedure in > Query Analyzer is successful and returns records so it must be ADO's > problem. > > Any ideas what ADO's problem is? > > Thanks in advance > > Craig > > btw I'm using ADO 2.7 with VB6 against SQL Server 2000 >
- Next message: William \(Bill\) Vaughn: "Re: Updating/Inserting rows in SQL Server 2000 with text data types"
- Previous message: Brendan Reynolds: "Re: SQL server data into Word?"
- In reply to: kaldvelski_at_yahoo.co.uk: "Stored Procedure returning a closed recordset"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|