Re: recordset not opening even though query analyzer returns resultset
- From: "William \(Bill\) Vaughn" <billvaNoSpam@xxxxxxxxx>
- Date: Fri, 10 Jun 2005 10:28:57 -0700
This is by design. As I discuss (in great detail) in my books, when you
execute a query the SQL engine returns a resultset. You use the Recordset
object to handle these. If the resultset has a rowset, the Recordset's State
is adStateOpen. If no rows were returned, you still get an "open" Recordset.
However, if you execute an SQL command that does not return a rowset (like
an UPDATE command), your Recordset tells you there is no rowset by setting
the State property to adStateClosed.
To remedy this, the easiest way is to turn off these rowsetless resultsets
by adding SET NOCOUNT ON in your SP. I don't suggest this as it discards the
"rows affected" value returned by the action command. Instead, you can
simply step to the next resultset returned by your query-- Set RS =
Rs.NextResult (or somesuch).
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
www.sqlreportingservices.net
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"steven scaife" <stevenscaife@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:691F66FD-18C1-421A-BAF0-A1303A1EDDB0@xxxxxxxxxxxxxxxx
>I have a query that runs a stored procedure which returns a resultset in
> query analyzer but when run in vb doesn't open a recordset
>
> I have tried set rs = conn.execute(strSQL)
> and
> rs.open strSQL, conn, adOpenForwardOnly , adLockReadOnly
>
> i get an error saying operation not allowed when object is closed
>
> I dont understand why it isn't opening when I get results from the same sp
> in query analyzer
>
> Does anyone have any ideas if you need more information just ask
.
- Follow-Ups:
- Re: recordset not opening even though query analyzer returns resul
- From: steven scaife
- Re: recordset not opening even though query analyzer returns resul
- References:
- recordset not opening even though query analyzer returns resultset
- From: steven scaife
- recordset not opening even though query analyzer returns resultset
- Prev by Date: Re: Executing UpdateBatch Asynchronously ?
- Next by Date: Please help "operation was canceled"
- Previous by thread: recordset not opening even though query analyzer returns resultset
- Next by thread: Re: recordset not opening even though query analyzer returns resul
- Index(es):
Relevant Pages
|