PDA

Click to See Complete Forum and Search --> : Using connectionless recordsets...


gwa584
Aug 28th, 2000, 08:44 AM
Hey everyone -
Anyone have much experience with connectionless ADO recordsets? (i.e. one where YOU put the data in it instead of the database engine)
For a vb / internet COM object project, I'm generating a report which requires a lot of processing of data, resorting, and processing again in order to get the data massaged as I need it for the report.
I've tried the steps in several guide sbut nothing seems to work and I'm thinking one small thing is wrong. The problem that occurs is that no matter what I try, when I add a second or third record to the recordset, they just overwrite the first and then the recordset only has one record in it.

Here's the code I've tried:

Dim rs As Recordset 'Create recordset
Set rs = New Recordset

With rs 'Setup column names
.Fields.Append "Name", adBSTR
.Fields.Append "BirthDate", adDate
End With

rs.Open 'Open Recordset

With rs 'Add one record
.AddNew
.Fields("Name") = "Fred"
.Fields("BirthDate") = "1/1/88"
.Update
End With

'rs.MoveNext <-- this was tried but didn't work

With rs 'Add another record
.AddNew
.Fields("Name") = "Mary"
.Fields("BirthDate") = "3/10/68"
.Update
End With

aData = rs.GetRows 'Stick all this data
Set rs = Nothing ' in an array
Debug.Print "Done."

gwa584
Aug 28th, 2000, 10:01 AM
I knew it was something basic...

If you've been adding records to a recordset and then want
to use the .GetRows() method on the recordset to store the
whole thing in an array, be SURE to first call .MoveFirst()!

Otherwise, it will output all the rows from that point on,
but will not fetch previous records... geesh.