hi,
Actually, I need to return a recordset from a function in ASP program code. But don't know how to do the same. Can anybody please suggest a correct way of returning a recordset from a function in ASP ?
thanks
hi,
Actually, I need to return a recordset from a function in ASP program code. But don't know how to do the same. Can anybody please suggest a correct way of returning a recordset from a function in ASP ?
thanks
I had the same problem where I used the following technique:
Create a function i.e. GetRecordSet and pass the sql string and the DSN string for flexibility.
ALthough function doesnt return a recordset, but it returns an array which you can get with getrows.
This technique is really fast and works well too. With this way, you can pass any kind of sql search statement and your return value would be an array representation of the resulting recordset. Also, you can open and close the DB connection and the recordset within the function itself.
setup a temporary Recordset. use this to open and gather information as you would normally. Then when your are ready, set your function equal to the tmp recordset and kill the the temp one....like in following example:
Public Function myFunction(var1,var1.....) as ADODB.Recordset
Dim myRS
'Open RS etc..
myRS.open sSQL, dbConn
'If Open then
set myFunction = myRS
If not myRS is nothing then
set myRs = nothing
End if
End Function
you can also use the name of the function directly as it can be use inside itself as a variable of the type it returns - in this case, an ADODB.Recordset.
Bookmarks