Re: sometimes endless loop, sometimes not



MiniMike wrote on Tue, 16 Aug 2005 01:53:07 -0700:

> I am sure that RS.MoveNext is inside the loop.
> But i was using On Error Resume Next, and did not check the error after
> showing a record. So this was pretty helpful for me. I'll change it, and
> check it again.
> Thanks !
> But it still confuses me a little bit; why would there be an error , and
> sometimes not? Nothing (not the page, not the data, ...) has changed.
> Would that be an access-bug or something?


To find out what the error is, add something to spit it out on the page just
after the loop, or remove the On Error Resume Next, eg.

If Err.Number <> 0 Then
Response.Write "Error occured: " & Err.Number & " " & Err.Description
End If

That way you can see what the error is when it happens, and start working to
resolve it. Without knowing the error number there's not much you can do. It
could be down to record locking for instance - Jet is not a reliable
multiuser database, and if you've got too many "users" accessing it at the
same time it's possible one will prevent another from reading the next
record - and then you're stuck until that lock is resolved. To avoid this
sort of thing you can try some of the following:

Ensure all recordsets are forwardonly readonly - this is normally the
default in ADO

Keep any editing of recordsets as quick as possible - don't use
Pessimistic locking if you can help it, and don't start editing a record and
then have your code do some long calculations before finishing changes and
issuing the .Update, as the record will be locked the whole time.

Make sure you're running Jet 4.0 as it has row level locking rather than
page level, and ensure that row level locking isn't being disabled.


For high traffic sites I'd recommend you move away from Access - I used to
use it on my web server and moved to SQL Server when I started getting
frequent timeouts and record locking issues, and poor performance when
searching for records. Haven't looked back since :)

Dan

> "Daniel Crichton" wrote:
>
>> MiniMike wrote on Tue, 16 Aug 2005 00:15:02 -0700:
>>
>>> 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.
>>
>> Are you sure you've got
>>
>> RS.MoveNext
>>
>> inside that Do ... Loop? If so, then the only other problem could be that
>> you've got an error occuring, you've got On Error Resume Next in your
>> script, and you're not checking for an error before the last record is
>> moved past - in which case RS.Eof is still false, but every attempt to
>> move to the next record fails. Try something like this:
>>
>> On Error Resume Next
>>
>> SQL = "Select * " _
>> & "from tblTable " _
>> & "order by intID desc"
>> Set RS = Conn.Execute(SQL)
>> If not RS.Eof And Err.Number = 0 Then
>> Do while not RS.Eof and Err.Number = 0
>> 'show this record on the site
>>
>> RS.MoveNext
>> Loop
>> End if
>> RS.Close
>> Set RS = Nothing
>>
>> Dan
>>


.



Relevant Pages

  • Re: sometimes endless loop, sometimes not
    ... > after the loop, or remove the On Error Resume Next, eg. ... and ensure that row level locking isn't being disabled. ... > use it on my web server and moved to SQL Server when I started getting ... >>> Dan ...
    (microsoft.public.data.ado)
  • Re: Non-rectangular 3D plot
    ... loop' properly to get x and y vectors and the z matrix. ... Roger Stafford wrote: ... rectangular space. ... There is an example of a sphere generated by 'surf' in the function reference ...
    (comp.soft-sys.matlab)
  • Re: Nonworking hours
    ... Dan wrote: ... resource pool, and so to check for 450 days for each one whether each day is ... Project MVP ... start and end dates of the project, so I can't simply loop on the start ...
    (microsoft.public.project)
  • Re: enhance m-files performance by compiling?
    ... as Dan already pointed out: ... Although MATLAB was invented ... of programming skills. ... about 100 lines, and one loop. ...
    (comp.soft-sys.matlab)
  • Re: Whats wrong with this code?? A97 XP SP2
    ... Thanks Dan - that makes sense, seems like there should be an easier way to ... and this is the first run for the routine. ... >> routine should use Like (for wildcards) ... >> Just working on the first part of the If - Loop for now. ...
    (microsoft.public.access.modulesdaovba)