Solved

Passing recordset back from function!

Posted on 2000-05-12
1
185 Views
Last Modified: 2011-09-20
I have a web page which has a function. The function queries a database and returns back a recordset.

The problem is I can't do the usual things that I can do with a regular recordset (like, MoveNext). Below's the code.


Dim objResource
Dim rsResources

rsResources = ShowResource()

Do While Not rsResouces.EOF

      Response.Write rsResources("resource_id") & ": " & rsResources("resource_name") & "<BR>"

      rsResources.MoveNext

      Response.Write rsResources("resource_name") & "<BR>"

Loop

Function ShowResource()

      Dim rsResource
      Dim conResource
      Dim strSQL
      Dim objCalendar
      Dim strDSN

      Set conResource = Server.CreateObject("ADODB.Connection")

      strDSN = "driver=sql server;database=db1;server=server1;uid=sa;pwd=password"

      conResource.Open strDSN
      
      strSQL = "sp_ShowRecords"

      Set rsResource = conResource.Execute(strSQL)

      Set ShowResource = rsResource
      
End Function
0
Comment
Question by:hobster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
MikeRenz earned 50 total points
ID: 2806234
change your
  Function ShowResource()
to
  Function ShowResource() as Recordset


if that doesn't do it for you, then you must use this:
 
  Function ShowResource(ByRef myRS)
    ...
    Set myRS = conResource.Execute(strSQL)
  End Function

and then call the function like this:

  ShowResource rsResource



btw...this question should be asked in the ASP section, not the VB section of EE
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question