By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,762 Members | 1,838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,762 IT Pros & Developers. It's quick & easy.

RecordSet without actual data behind it

P: n/a
I would like to use an ADODB.RecordSet object to temporarily store some data
and then iterate through it. Actually it needs to be a RecordSet only
because it is a perfect choice as data structure for what I want to do, I
don't want to actually run queries or update tables with it.
It seems to me, however, that the RecordSet works only if there's a query
behind it. ADO complains about the RecordSet not being open when I try to
add rows by the AddNew function, or try to add fields to it.

Is there a way to use the RecordSet without actual database date behind it?
Or is there maybe some object in VBScript that provides the same or at least
similar functionality? (Apart from Scripting.Dictionary, which is great, but
I would like to use something more similar. :) )

Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
If I remember steps are :
- create the recordset
- append the fields
- open the recordset
- add data

Seesing some code that repor the problme may help...

Patrice

--

"Agoston Bejo" <gu***@freemail.hu> a écrit dans le message de
news:ee**************@TK2MSFTNGP15.phx.gbl...
I would like to use an ADODB.RecordSet object to temporarily store some data and then iterate through it. Actually it needs to be a RecordSet only
because it is a perfect choice as data structure for what I want to do, I
don't want to actually run queries or update tables with it.
It seems to me, however, that the RecordSet works only if there's a query
behind it. ADO complains about the RecordSet not being open when I try to
add rows by the AddNew function, or try to add fields to it.

Is there a way to use the RecordSet without actual database date behind it? Or is there maybe some object in VBScript that provides the same or at least similar functionality? (Apart from Scripting.Dictionary, which is great, but I would like to use something more similar. :) )

Jul 19 '05 #2

P: n/a
This should answer your question:

http://www.4guysfromrolla.com/webtech/071799-1.shtml

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Agoston Bejo" <gu***@freemail.hu> wrote in message
news:ee**************@TK2MSFTNGP15.phx.gbl...
I would like to use an ADODB.RecordSet object to temporarily store some data and then iterate through it. Actually it needs to be a RecordSet only
because it is a perfect choice as data structure for what I want to do, I
don't want to actually run queries or update tables with it.
It seems to me, however, that the RecordSet works only if there's a query
behind it. ADO complains about the RecordSet not being open when I try to
add rows by the AddNew function, or try to add fields to it.

Is there a way to use the RecordSet without actual database date behind it? Or is there maybe some object in VBScript that provides the same or at least similar functionality? (Apart from Scripting.Dictionary, which is great, but I would like to use something more similar. :) )

Jul 19 '05 #3

P: n/a
You need to create a disconnected recordset.

Basic structure of a disconnected recordset:

'-------------------Start Code----------------------------
'Create the Disconnected Recordset
Dim RS As Recordset
Set RS = New Recordset

'Setup the Recordset
With RS
'Make sure there is no active connection
.ActiveConnection = Nothing

'Set for client side processing
.CursorLocation = adUseClient

'Single user updates
.LockType = adLockBatchOptimistic
End With

'Add Fields and Values to Recordset
With RS.Fields
.Append "ID", adBSTR
.Append "Company", adBSTR
.Append "Description", adBSTR
End With

'Open the Recordset
RS.Open

'Populate the Data in the Recordset
With RS
.AddNew
.Fields("ID") = "ID123"
.Fields("Company") = "Some Company"
.Fields("Description") = "Description"
End With
'-------------------------End Code---------------------------
--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
--

"Agoston Bejo" <gu***@freemail.hu> wrote in message
news:ee**************@TK2MSFTNGP15.phx.gbl...
I would like to use an ADODB.RecordSet object to temporarily store some data and then iterate through it. Actually it needs to be a RecordSet only
because it is a perfect choice as data structure for what I want to do, I
don't want to actually run queries or update tables with it.
It seems to me, however, that the RecordSet works only if there's a query
behind it. ADO complains about the RecordSet not being open when I try to
add rows by the AddNew function, or try to add fields to it.

Is there a way to use the RecordSet without actual database date behind it? Or is there maybe some object in VBScript that provides the same or at least similar functionality? (Apart from Scripting.Dictionary, which is great, but I would like to use something more similar. :) )

Jul 19 '05 #4

P: n/a
Veign wrote:
You need to create a disconnected recordset.


Just a little nitpick:
He actually needs to create an "ad hoc" recordset, not "disconnected", since
"disconnected" implies that a previously connected recordset has been
disconnected by setting the ActiveConnection property to Nothing. A
disconnected recordset can be reconnected to the data source. An ad hoc
recordset, since it never was connected to a data source, cannot be
connected after it is open.

Bob Barrows

--
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"
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.