Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > return dictionary from a function

Reply
Thread Tools

return dictionary from a function

 
 
JT
Guest
Posts: n/a
 
      09-29-2003
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


 
Reply With Quote
 
 
 
 
Mark Schupp
Guest
Posts: n/a
 
      09-29-2003
Set ExecSQL = objDictionary


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


"JT" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance ordered dictionary vs normal dictionary Navkirat Singh Python 6 07-29-2010 10:18 AM
Function return a dictionary Boris Mok Python 2 10-01-2007 08:05 AM
creating a dictionary from a dictionary with regex james_027 Python 1 08-22-2007 07:39 AM
[DICTIONARY] - Copy dictionary entries to attributes Ilias Lazaridis Python 6 02-21-2006 11:27 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM



Advertisments