PDA

View Full Version : Problem with .movenext


LondonBoy
08-31-2006, 05:26 PM
Hi All,

I'm currently working on code that was written by a previous developer.
I'm a PHP Developer but one project was done in ASP before my arrival.

This is the code

<form name="form1">
<%
i=1
Do While not rsProds.eof
st=i
if i<10 then st="0"&i
v1=rsProds("Value")
rsProds.movenext
v2=rsProds("Value")
rsProds.movenext
sel=""
If getSession("dimAlias")=v1&"x"&v2 Then sel=" checked"
%>
<tr id="tr<%=st%>" value="<%=v1&"x"&v2%>">
<td class="dim0" align="center"><%= v1 %></td>
<td class="dim0" align="center"><%= v2 %></td>
<td class="dim0" align="center"><input name="optdim" type="radio" value="<%=v1&"x"&v2%>" onclick="setColor('tr<%=st%>')"<%= sel %> /></td>
</tr>
<%rsProds.movenext
i=i+1
Loop
%>


I get an error saying: ADODB.Recordset error '800a0bcd'
the line is bold is what the error log is saying is the offending line.

Can anyone help me out with this?

This is what rsProds is in case anyone needs that info to help me out:
set rsProds=OpenRecordSet(db, sqlLstProds, 1,3)

Thanks alot
BK

Wylie
08-31-2006, 07:27 PM
800a0bcd means that rsProds.eof is true. I found you have 3 movenext of each looping, perhaps this is cause of your problem.

LondonBoy
08-31-2006, 08:48 PM
so what should I do?

Is there a while loop too many?

Wylie
08-31-2006, 09:21 PM
The problem is not looping too many, it is reading too many. This looping read 3 records from db, but it stops the loop processes if no more record. What you have to do is, try to stop your program read any data from db when eof.

LondonBoy
08-31-2006, 09:42 PM
hmmmmmmmm
lol, how would I do that?

i'm a PHP developer, not ASP

This code was written by someone else before my arrival

hope u can help.

Thanks

Wylie
08-31-2006, 10:29 PM
if rsProds.eof Then Exit Do


This line should helped, you can placed this before a line that read db. (each line with rsProds("Value"))
Something I cannot understand. Why this loop read 2 record but with 3 movenext? I think you have to question on this too, if you do not know the reason. You may better to put if rsProds.eof Then Exit Do before the last movenext too. Well, it seems your previous developer leave you alot question on this. good luck

LondonBoy
09-01-2006, 02:31 PM
so you mean I should do this?
In bold is the code you provided Wylie, to which I apreciate.


<% set rsProds=OpenRecordSet(db, sqlLstProds, 1,3)%>

<form name="form1">
<%
i=1
Do While not rsProds.eof
st=i
if i<10 then st="0"&i
if rsProds.eof Then Exit Do
v1=rsProds("Value")
rsProds.movenext
if rsProds.eof Then Exit Do
v2=rsProds("Value")
rsProds.movenext
sel=""
If getSession("dimAlias")=v1&"x"&v2 Then sel=" checked"
%>
<tr id="tr<%=st%>" value="<%=v1&"x"&v2%>">
<td class="dim0" align="center"><%= v1 %></td>
<td class="dim0" align="center"><%= v2 %></td>
<td class="dim0" align="center"><input name="optdim" type="radio" value="<%=v1&"x"&v2%>" onclick="setColor('tr<%=st%>')"<%= sel %> /></td>
</tr>
<%
if rsProds.eof Then Exit Do
rsProds.movenext
i=i+1
Loop
%>

Wylie
09-01-2006, 08:23 PM
Yes, and you can remove the first if rsProds.eof Then Exit Do that is after if i<10 then st="0"&i.