How to rewind a recordset from Cmd.Execute
am 22.08.2007 00:40:00 von m_j_sorens
I want to invoke the Execute method of a Command to obtain a record set, then
reuse that record set twice. A rough code outline appears below. It appears
that the record set return from Command.Execute is non-rewindable, however;
upon attempting the second "MoveFirst" I get this error:
"error '80040e18' Rowset position cannot be restarted."
Is there a straightforward way to make this record set reusable?
==========================
Set Cmd=CreateObject("ADODB.Command")
Cmd.CommandText = sqlText
Set Cmd.ActiveConnection=MyConnection
arParams = Array(IDCustomer, IDUser)
Set rs = Cmd.Execute(,arParams, adCmdText)
<%rs.MoveFirst
Do While Not rs.EOF%>
.. . .
<%rs.MoveNext
Loop%>
.. . .
<%rs.MoveFirst
Do While Not rs.EOF%>
.. . .
<%rs.MoveNext
Loop%>
==========================
Re: How to rewind a recordset from Cmd.Execute
am 22.08.2007 07:55:08 von reb01501
michael sorens wrote:
> I want to invoke the Execute method of a Command to obtain a record
> set, then reuse that record set twice.
Silly.
Use GetRows to stuff the data into an array, close your connection and
recordset, and do whatever you want to do with the data.
Remember, the idea is to get into the database, get your data or perform
your tasks, and _immediately get back out of the database_
See http://www.aspfaq.com/show.asp?id=2467 for an example of using GetRows
(and GetString for that matter)
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: How to rewind a recordset from Cmd.Execute
am 22.08.2007 18:38:02 von m_j_sorens
I agree, it was a rather silly question... my only excuse is that I am still
getting my feet wet and do not yet know my way around the libraries for
ASP/VBScript sufficiently. Your solution is what had immediately come to mind
but I did not quite know where to look to implement it. Thanks for pointing
me to precisely what I needed.