loop recordset adding fields to data dictionary

Discussion in 'ASP General' started by JT, Apr 20, 2004.

  1. JT

    JT Guest

    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
     
    JT, Apr 20, 2004
    #1
    1. Advertising

  2. JT wrote:
    > 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
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Apr 20, 2004
    #2
    1. Advertising

  3. JT

    roger Guest

    "JT" wrote
    > 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

    --
    roger
     
    roger, Apr 21, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven K

    Loop Through a recordset

    Steven K, Mar 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,342
    Kirk Graves
    Mar 4, 2004
  2. Gian Paolo Clarici
    Replies:
    0
    Views:
    827
    Gian Paolo Clarici
    Jul 21, 2004
  3. Hung Huynh
    Replies:
    8
    Views:
    349
    Bob Barrows
    Sep 24, 2003
  4. Darren Smith
    Replies:
    2
    Views:
    173
    Darren Smith
    Jan 28, 2004
  5. Isaac Won
    Replies:
    9
    Views:
    458
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page