Re: Ado Recordset and stored procedure(SQL server 2000)
- From: "Ralph" <nt_consulting64@xxxxxxxxx>
- Date: Fri, 3 Nov 2006 12:33:25 -0600
"Mark J. McGinty" <mmcginty@xxxxxxxxxxxxxxx> wrote in message
news:OHlijM3$GHA.4292@xxxxxxxxxxxxxxxxxxxxxxx
recordsets,
"chris" <chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:071A04A1-E170-45FA-BC0F-65040DB637FE@xxxxxxxxxxxxxxxx
Good day:
I am having the most difficult time with what should be a simple task.
I want to fill a recordset using a stored procedure. The recordset does
not
even open. The error message is ...cannot complete operation on closed
recordset...
Dim rs as new adodb.recordset
rs.open "SP_GetTriplicate '10/30/2006 09:00:01', '10/31/2006 09:00:00',
3",cnn, adOpenKeyset, adLockOptimistic, adCmdStoredProc
do while not rs.eof
something
rs.movenext
loop
I have also tried the techniques with the ado command object and
parameters
to no avail.
The problem is that your stored procedure is returning multiple
not all of which contain records. Add the line:recordset
SET NOCOUNT ON
to the top of your stored procedure, to prevent the non-row-returning
statements from generating empty recordsets.
Alternatively, you could call rs.NextRecordset until it returns a
object for which rs.State = 1, but that would just be meaningless overheadwant
in this case. (It's useful when the stored procedure or SQL statement
actually does return multiple recordsets.)
An aside that has nothing to do with your problem specifically, you should
avoid naming your stored procedures with "sp_" as a prefix, unless you
a procedure to be callable from any database (and are willing to incur the<snipped>
slight amount of extra overhead associated with this naming convention.)
-Mark
LOL
I totally missed multiple recordsets.
Talk about one's Doh! moments.
-ralph
.
- References:
- Ado Recordset and stored procedure(SQL server 2000)
- From: chris
- Re: Ado Recordset and stored procedure(SQL server 2000)
- From: Mark J. McGinty
- Ado Recordset and stored procedure(SQL server 2000)
- Prev by Date: Re: Ado Recordset and stored procedure(SQL server 2000)
- Next by Date: Re: delete a row in my table
- Previous by thread: Re: Ado Recordset and stored procedure(SQL server 2000)
- Next by thread: Re: ADO query to Access not working, no errors
- Index(es):
Relevant Pages
|