Re: How to create editable recordset without using a database table?



John Dalberg schrieb:
Is there a way to create a dataset in VBScript without doing a query to a
real table? Can I define the recordset's fields and types through vbscript
only?

I want to use the recordset for memory use only. I can't use database
tables or xml files.


The record set needs to be editable.

John Dalberg

If "dataset" doesn't imply .NET, you can use a "disconnected recordset"
(Classic ADO). This sample code (using such a recordset to sort an array)

Sub sortLinesAdo( aLines )
Const adVarWChar = 202 ' 000000CA
Dim oRS : Set oRS = CreateObject( "ADODB.Recordset" )
Dim nIdx

oRS.Fields.Append "Fld0", adVarWChar, 2000
oRS.Open

For nIdx = 0 To UBound( aLines )
oRS.AddNew
oRS.Fields( 0 ).value = aLines( nIdx )
oRS.UpDate
Next
If Not (oRS.BOF Or oRS.EOF) Then
oRS.Sort = "Fld0"
nIdx = 0
oRS.MoveFirst
Do Until oRS.EOF
aLines( nIdx ) = oRS( "Fld0" ).value
nIdx = nIdx + 1
oRS.MoveNext
Loop
End If
End Sub

shows some important actions that can be done to such a beast. Whether
it will be good for you, depends on what you want to achieve.
.