return dictionary from a function

J

JT

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
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top