473,508 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RecordSet without actual data behind it

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
4 4729
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
9288
by: Adam Short | last post by:
I am trying to write a routine that will connect a .NET server with a classic ASP server. I know the following code doesn't work! The data is being returned as a dataset, however ASP does not...
2
10659
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
1
2457
by: Edward | last post by:
I've recently migrated the back end of one of my client's applications from Access to SQL Server. One of the forms is based on an Access query thus: SELECT dbo_tblDistributionDetail.*,...
6
13988
by: Andy Barber | last post by:
Hi, I'm trying to write an app that reads data from a table into a string variable for later use in my program. Below is a snippet of the code I'm using, which compiles ok, but at runtime I get...
36
4413
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
5
3037
by: slowmotiongenius | last post by:
All- I have established an adodb recordset in my code-behind, and I need to pass it to the aspx file. I can't seem to figure out if there is a way to do this. I see you can pass a string over...
6
1619
by: AJ | last post by:
Hi all, I am trying to execute the following code: 'create recordset object SET recData = Server.CreateObject("ADODB.recordset") 'open recordset recData.Open "exec...
4
1502
by: Joseph | last post by:
Hi all- I am a former VB6 programmer and new at C# and I have a question dealing with converting some code from VB6 to C#. The code is below and essentially, what it does is gets data from a SQL...
5
1592
by: joe donnelly | last post by:
I have a couple of questions about recordsets: 1. When a recordset is summoned by the code where does it actually exist and in what form...is it created in the database (data source location)...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.