Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Passing recordset back from function!

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
hobster
Asked:
hobster
1 Solution
 
MikeRenzCommented:
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now