Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 21st, 2004, 11:07 AM
Authorized User
Points: 447, Level: 7
Points: 447, Level: 7 Points: 447, Level: 7 Points: 447, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Adrian, MI, USA.
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get a function to return a recordset object

Code:
function funOne(sql)

  Dim rsOne

  Set rsOne = Server.CreateObject("ADODB.RecordSet")
  rsOne.Open sql, oConn

  Set funOne = rsOne

  rsOne.Close
  Set rsOne = Nothing

end function
Code:
function funTwo()

  Dim rsTwo

  Set rsTwo = funOne("SELECT .....")

  funTwo = rsTwo(1)

  rsTwo.Close
  Set rsTwo = Nothing

end function
Can anyone see anything wrong with this? If someone has passed a RS object from on function to another I would be very pleased if you would share the code.

Thanks
dog
Reply With Quote
  #2 (permalink)  
Old September 21st, 2004, 11:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I have a feeling that the problem is that the recordset is closed. Try making rsone global.

Brian
Reply With Quote
  #3 (permalink)  
Old September 22nd, 2004, 02:39 AM
Friend of Wrox
 
Join Date: Sep 2004
Location: Hyderabad, Andhra Pradesh, India.
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshbabu Send a message via Yahoo to sureshbabu
Default

Hi,
   I feel the same. Just use the following code . Here I just commented last but one line in the first function(rsOne.Close)
It will work

function funOne(sql)

  Dim rsOne

  Set rsOne = Server.CreateObject("ADODB.RecordSet")
  rsOne.Open sql, oConn

  Set funOne = rsOne

  'rsOne.Close
  Set rsOne = Nothing

end function

Thank You
Suresh




Reply With Quote
  #4 (permalink)  
Old September 22nd, 2004, 03:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

I don't think the last 2 lines in that function are required. Also SET keyword is not required there. But you got to use SET at the location where you call this function.

...
  Set funOne = rsOne

  'rsOne.Close
  Set rsOne = Nothing
...

As you set a value to the FUNCTION name, there by the control goes out of that function to where it is being called. So there shouldn't be any chance of executing the last 2 lines given above.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can i return a recordset in a Stored procedure chiefouko VB Databases Basics 6 December 12th, 2006 03:34 AM
function return 'Nothing' problem srinuRocks ASP.NET 2.0 Basics 0 March 10th, 2005 10:32 AM
How to return array value from a function nebpro BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 September 29th, 2004 12:14 PM
Return a UDT from a function alex_read Pro VB 6 1 April 23rd, 2004 05:37 AM
Can i return a recordset in a Stored procedure chiefouko SQL Server 2000 1 June 23rd, 2003 06:13 AM



All times are GMT -4. The time now is 12:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.