PDA

View Full Version : Returning a RecordSet


Hatch
06-06-2003, 11:08 PM
How do you return a record set from a function?
I have...
===============================
public Function listAllItems
Connect blah blah ...

strSQL1="SELECT * from CartItems;"
objRS.Open strSQL1, objConn

listAllItems = objRS()
End Function
================================

Then the other page I have.....

Set objShoppingCart = New classShoppingCart
Set objItem = New classItem

bob = objItem.listAllItems
response.write(bob)

When I do this I get an error.
Does anyone know how to do this?
Please let me know.
Thanks

Roy Sinclair
06-06-2003, 11:12 PM
public Function listAllItems
Connect blah blah ...

strSQL1="SELECT * from CartItems;"
objRS.Open strSQL1, objConn

set listAllItems = objRS()
End Function


Of course when you go to .NET the word set is no longer needed or even valid. Go figure :) .

Hatch
06-06-2003, 11:17 PM
Thanks for the quick response. I added set in there and i'm getting ...

Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'objRS'

Do you know why this is?
TiA

Roy Sinclair
06-24-2003, 04:30 PM
Been on vacation,

set listAllItems = objRS

Leave off the () and it'll work.