return dictionary from a function

Discussion in 'ASP General' started by JT, Sep 29, 2003.

  1. JT

    JT Guest

    im trying to create a function that accepts a sql statement as a parameter,
    makes a db connection, returns a recordset, and inserts all items from the
    recordset into a data dictionary - then i want to set the value of my
    function equal to my newly created dictionary of items from the recordset -
    this is where im having a problem. is it possible to set a function equal
    to a dictionary? i cant seem to make this work and it seems that this
    should be possible.

    here is some sample code:

    Function ExecSQL(strSQL)

    Set objDBInterface = Server.CreateObject("SPP.DBInterface")
    Set rs = Server.CreateObject("ADODB.Recordset")
    Set objDictionary = Server.CreateObject("Scripting.Dictionary")

    sql = strSQL

    objDBInterface.sql = sql
    Set rs = objDBInterface.SelectSQL

    ' add rs to dictionary
    for each field in rs.Fields
    objDictionary.Item(Field.Name) = Field.Value
    next

    ***asp is complaining here!!!#$@
    ExecSQL = objDictionary

    End if

    End Function


    'this is how im calling the function
    rsDict = ExecSQL(sql)


    tia
    jt
    JT, Sep 29, 2003
    #1
    1. Advertising

  2. JT

    Mark Schupp Guest

    Set ExecSQL = objDictionary


    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "JT" <> wrote in message
    news:...
    > im trying to create a function that accepts a sql statement as a

    parameter,
    > makes a db connection, returns a recordset, and inserts all items from the
    > recordset into a data dictionary - then i want to set the value of my
    > function equal to my newly created dictionary of items from the

    recordset -
    > this is where im having a problem. is it possible to set a function equal
    > to a dictionary? i cant seem to make this work and it seems that this
    > should be possible.
    >
    > here is some sample code:
    >
    > Function ExecSQL(strSQL)
    >
    > Set objDBInterface = Server.CreateObject("SPP.DBInterface")
    > Set rs = Server.CreateObject("ADODB.Recordset")
    > Set objDictionary = Server.CreateObject("Scripting.Dictionary")
    >
    > sql = strSQL
    >
    > objDBInterface.sql = sql
    > Set rs = objDBInterface.SelectSQL
    >
    > ' add rs to dictionary
    > for each field in rs.Fields
    > objDictionary.Item(Field.Name) = Field.Value
    > next
    >
    > ***asp is complaining here!!!#$@
    > ExecSQL = objDictionary
    >
    > End if
    >
    > End Function
    >
    >
    > 'this is how im calling the function
    > rsDict = ExecSQL(sql)
    >
    >
    > tia
    > jt
    >
    >
    Mark Schupp, Sep 29, 2003
    #2
    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. Ilias Lazaridis
    Replies:
    6
    Views:
    437
    Ilias Lazaridis
    Feb 21, 2006
  2. Greenhorn
    Replies:
    15
    Views:
    812
    Keith Thompson
    Mar 6, 2005
  3. james_027
    Replies:
    1
    Views:
    322
    Marc 'BlackJack' Rintsch
    Aug 22, 2007
  4. Boris Mok

    Function return a dictionary

    Boris Mok, Oct 1, 2007, in forum: Python
    Replies:
    2
    Views:
    296
    Duncan Booth
    Oct 1, 2007
  5. Navkirat Singh
    Replies:
    6
    Views:
    3,027
    Navkirat Singh
    Jul 29, 2010
Loading...

Share This Page