access - recordset - sometimes endless loop, sometimes not
am 16.08.2005 09:17:02 von MiniMike
I'm having this very weird problem on my website. I'm using ASP, and an
Access 2003 database.
The problem is this:
When i surf to my page, there's usually no problem.
I have this select statement :
SQL = "Select * " _
& "from tblTable " _
& "order by intID desc"
Set RS = Conn.Execute(SQL)
If not RS.Eof Then
Do while not RS.Eof
'show this record on the site
Loop
End if
My recordset is loaded, and i show the records on the site. There are only 4
records for now.
But, sometimes, when i surf to my page (just the same page, just the same
query, only other time), my page goes into an endless loop.
Anyone with any ideas on this? The strange thing is, though it's the same
page, i reacts different on different times.
Re: access - recordset - sometimes endless loop, sometimes not
am 16.08.2005 13:02:00 von reb01501
MiniMike wrote:
> I'm having this very weird problem on my website. I'm using ASP, and
> an Access 2003 database.
>
> The problem is this:
> When i surf to my page, there's usually no problem.
> I have this select statement :
> SQL = "Select * " _
http://www.aspfaq.com/show.asp?id=2096
> & "from tblTable " _
> & "order by intID desc"
> Set RS = Conn.Execute(SQL)
> If not RS.Eof Then
This line is redundant - you are checking for EOF in your loop
> Do while not RS.Eof
> 'show this record on the site
Hopefully there's an "RS.MoveNext" statement in this loop ...
> Loop
> End if
Hopefully you are closing and destroying your recordset and connection
objects ...
>
> My recordset is loaded, and i show the records on the site. There are
> only 4 records for now.
>
> But, sometimes, when i surf to my page (just the same page, just the
> same query, only other time), my page goes into an endless loop.
>
I suspect the recordset loop is not the problem, but you are going to have
to do some debugging to find out.
Start out by disqualifying the loop as the source of your problem by using a
counter to break out of the loop. For debugging purposes, run a second query
to get the count of the records that are returned:
Set RS = Conn.Execute("select count(*) from tblTable",,1)
recs=RS(0)
RS.close
Set RS = Conn.Execute(SQL,,1)
i=1
Do Until RS.EOF
If i > recs then
response.write "
Breaking out of loop
"
exit loop
end if
'display the record
i = i + 1
RS.MoveNext
Loop
Test the page and see if you ever see the "Breaking ... " message. If not,
the problem lies elsewhere.
You should consider trying the debugging techniques shown in this article:
http://support.microsoft.com/kb/299986/EN-US/
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"