tags:

views:

31

answers:

1

I'm using VB6 and trying to create a DAO recordset from an array of data. I want something like this but I've hit all kinds of problems

Dim rst As DAO.Recordset
Dim tdf As New DAO.TableDef
Dim fld As New DAO.Field

rst.Fields.Append tdf.CreateField(arrayHeader(0), adInteger, 5)
rst.OpenRecordset

rst.AddNew Array(arrayHeader(0), arrayHeader(1)), Array (arrData(0), arrData(1))

Code is simplified to highlight the problem I have. Arrays are declared and have data in them. Problem at the moment is trying to add the field to the recordset. Is it possible to have a disconnected DAO RecordSet like this? I have to use DAO for various reasons that really aren't worth getting into.

+2  A: 

It is not possible to fabricate a DAO Recordset in that way. A DAO Recordset cannot be disconnected; it needs to be always connected to a data source.

For what it's worth, a disconnected ADODB Recordset can be fabricated in almost exactly the way you have coded.

onedaywhen
Thanks for the response, I did know ADO RecordSets would work. Guess I'll have to write the data back to a db before I can use it.
Ralph