loop recordset adding fields to data dictionary

J

JT

how can i loop through all the fields in a recordset adding a collection of
name/value pairs to a data dictionary where name is the field name and value
is the field value. this is what i have so far (not working, of course..)
this is will only be used for one row recordsets.

dim d
set d = CreateObject("Scripting.Dictionary")

for each field in rsGetData.Fields
d.Add LCase(field), rsGetData.Fields(field)
Next

tia
jt
 
B

Bob Barrows [MVP]

JT said:
how can i loop through all the fields in a recordset adding a
collection of name/value pairs to a data dictionary where name is the
field name and value is the field value. this is what i have so far
(not working, of course..)

Please define "not working". Error message? Wrong result?
this is will only be used for one row recordsets.

dim d
set d = CreateObject("Scripting.Dictionary")

for each field in rsGetData.Fields
d.Add LCase(field), rsGetData.Fields(field)
Next

This is what I would do:

'disconnect the recordset and close the connection:
set rsGetData.ActiveConnection=nothing
conn.close:set conn = nothing

'now write the dictionary items:
for each fld in rsGetData.Fields
d.Add LCase(fld.name), fld.value
next

Bob Barrows
 
R

roger

for each field in rsGetData.Fields
d.Add LCase(field), rsGetData.Fields(field)
Next

Does this work?

for each field in rsGetData.Fields
d.Add LCase(field.name), field.value
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top