Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19-06-2009
Member
 
Join Date: Feb 2009
Posts: 64
How to return a recordset from a function in ASP

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
Reply With Quote
  #2  
Old 19-06-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: How to return a recordset from a function in ASP

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.
Reply With Quote
  #3  
Old 19-06-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: How to return a recordset from a function in ASP

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
Reply With Quote
  #4  
Old 19-06-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: How to return a recordset from a function in ASP

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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to return a recordset from a function in ASP"
Thread Thread Starter Forum Replies Last Post
SSH return function Elizabeth Allen Networking & Security 5 22-04-2010 02:38 PM
Is it possible for a function to return two values? hounds Software Development 5 13-03-2010 07:51 PM
How can I return different class in one function? Madaleno Software Development 4 10-02-2010 09:45 PM
Return string from a function in C Samarth Software Development 3 28-12-2009 12:24 PM
How to return an array from function Rilex Software Development 3 02-10-2009 09:18 AM


All times are GMT +5.5. The time now is 12:26 AM.