Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passing recordset back from function!

Posted on 2000-05-12
1
Medium Priority
?
188 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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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