Hi,

I have been all over the web looking for a definitive answer to this
question. I want to have a function which grabs a record set, and
returns it. Then, after my function call, I want to use something like
EOF or GetRows() to cycle through the record set. But no matter what I
try, I get the following error:

Object doesn't support this property or method: 'currentRow.EOF'

-----------------

Code returning set from function:

<snip>
rs.Open cmd, , adOpenStatic, adLockReadOnly
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
set rs.ActiveConnection = Nothing
oConn.Close
Set oConn = Nothing
getReportLogRow = rs ' This is the return statement
End Function

----------

Code using the returned recordset:

<snip>

Set currentRow = CreateObject("ADODB.Recordset")
Set currentRow = getReportLogRow(sessID)
if(currentRow.EOF)then

<snip>
---------------------

If I can solve this... I'm gonna publish the solution all over the
place because I can't be the only one ripping out their hair over this.
Why does vbscript-asp make using functions such a pain? ;)

Thanks for any help!

Re: Returning recordset from a function and using EOF by sherri

sherri
Thu Nov 09 11:40:42 CST 2006

Solved my own dilemma:

The return statement must use 'Set' :

Set getReportLogRow = rs

(Doh!)


Re: Returning recordset from a function and using EOF by bob

bob
Thu Nov 09 11:43:00 CST 2006

eof is a propert of the RS.

example....

Do While Not RS.EOF
'display record data
RS.MoveNext
Loop



<sherri.wheeler@gmail.com> wrote in message
news:1163093864.919528.249950@b28g2000cwb.googlegroups.com...
> Hi,
>
> I have been all over the web looking for a definitive answer to this
> question. I want to have a function which grabs a record set, and
> returns it. Then, after my function call, I want to use something like
> EOF or GetRows() to cycle through the record set. But no matter what I
> try, I get the following error:
>
> Object doesn't support this property or method: 'currentRow.EOF'
>
> -----------------
>
> Code returning set from function:
>
> <snip>
> rs.Open cmd, , adOpenStatic, adLockReadOnly
> Set cmd.ActiveConnection = Nothing
> Set cmd = Nothing
> set rs.ActiveConnection = Nothing
> oConn.Close
> Set oConn = Nothing
> getReportLogRow = rs ' This is the return statement
> End Function
>
> ----------
>
> Code using the returned recordset:
>
> <snip>
>
> Set currentRow = CreateObject("ADODB.Recordset")
> Set currentRow = getReportLogRow(sessID)
> if(currentRow.EOF)then
>
> <snip>
> ---------------------
>
> If I can solve this... I'm gonna publish the solution all over the
> place because I can't be the only one ripping out their hair over this.
> Why does vbscript-asp make using functions such a pain? ;)
>
> Thanks for any help!
>



Re: Returning recordset from a function and using EOF by OfficeGuyGoesWild

OfficeGuyGoesWild
Thu Nov 09 15:18:06 CST 2006

Hi,

Here is the complete syntax that you would need in an asp file:

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("db\Database.mdb")
Set rsMain = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT Title FROM tblData;"
rsMain.Open strSQL, adoCon
Do While NOT rsMain.EOF
Response.Write (rsMain("Title") & "<br>")
RsMain.MoveNext
Loop
rsMain.Close
Set adoCon = Nothing




The following is assumed:
1. you have a subdirectory called db which contains an MSAccess
database called Database.mdb
2. You have a table in this database called tblData
3. You have a column in tblData called Title


ps.. if you want to loop through the record set again, you can do
rsMain.MoveFirst . In this way you can reuse the recordset without
having to close and open it again.

..Marty
www.TheScriptLibrary.com

ps.. I have loaded this up to the www.thescriptlibrary.com with the
following url:

http://www.thescriptlibrary.com/default.asp?Action=Display&Level=Category3&ScriptLanguage=ASP&Category1=Database&Category2=Recordset&Title=Loop%20through%20a%20Recordset%20from%20an%20Access%20Database

or:

http://tinyurl.com/yg4t8m



sherri.wheeler@gmail.com wrote:
> Hi,
>
> I have been all over the web looking for a definitive answer to this
> question. I want to have a function which grabs a record set, and
> returns it. Then, after my function call, I want to use something like
> EOF or GetRows() to cycle through the record set. But no matter what I
> try, I get the following error:
>
> Object doesn't support this property or method: 'currentRow.EOF'
>
> -----------------
>
> Code returning set from function:
>
> <snip>
> rs.Open cmd, , adOpenStatic, adLockReadOnly
> Set cmd.ActiveConnection = Nothing
> Set cmd = Nothing
> set rs.ActiveConnection = Nothing
> oConn.Close
> Set oConn = Nothing
> getReportLogRow = rs ' This is the return statement
> End Function
>
> ----------
>
> Code using the returned recordset:
>
> <snip>
>
> Set currentRow = CreateObject("ADODB.Recordset")
> Set currentRow = getReportLogRow(sessID)
> if(currentRow.EOF)then
>
> <snip>
> ---------------------
>
> If I can solve this... I'm gonna publish the solution all over the
> place because I can't be the only one ripping out their hair over this.
> Why does vbscript-asp make using functions such a pain? ;)
>
> Thanks for any help!