Results 1 to 4 of 4

Thread: How to return a recordset from a function in ASP

  1. #1
    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

  2. #2
    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,501,152.68988 seconds with 16 queries