Can I use a function to return a recordset in classic ASP

I've recently switched from ASP to ASP.NET but I currently working on site that uses ASP.

In .NET I can use a DAL layer class and return a dataset to an object. I'm trying to do the same in ASP.

So, forgetting the classes etc and simplifying the matter I basically just need something like:

rsData = getDataset("SELECT * FROM table")
If Not rsData.Eof Then
         'Do my thing...
End If

Public Function getDataset(strSQL)
      getDataset = DBConn.Execute(strSQL)
End Function

I get "Object doesn't support this property or method: 'Eof'" so I guess I can't return a dataset.


w3digitalAsked:
Who is Participating?
 
kelvinwkwConnect With a Mentor Commented:
Public Function getDataset(strSQL)
    set  getDataset = DBConn.Execute(strSQL)
End Function

this will  do
0
 
kelvinwkwCommented:
to assign an object to a variable you need to use SET

SET <variable> = object
0
 
kelvinwkwCommented:
Forgot to write down something that is needed

set rsData = getDataset("SELECT * FROM table")
0
 
w3digitalAuthor Commented:
Marvellous!

Thank you very much indeed!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.