Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   return dictionary from a function (http://www.velocityreviews.com/forums/t790574-return-dictionary-from-a-function.html)

JT 09-29-2003 04:13 PM

return dictionary from a function
 
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 09-29-2003 05:54 PM

Re: return dictionary from a function
 
Set ExecSQL = objDictionary


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


"JT" <jeffreyl@sppinc.net> wrote in message
news:uRA55PqhDHA.3784@tk2msftngp13.phx.gbl...
> 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
>
>





All times are GMT. The time now is 07:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.