Problems with do Exception Occured error with an If statement in a Do While loop

  • 14 years ago

    Hi guys this is my first time on this forum , sorry i couldn't work out how to format the code below to make it easier to read....

    Basically when i run this code i'm getting the error Exception Occured at the first If Then statement below.

    However if i remove the do while loop it works fine and will display the first weeks worth of data i have, however i really want it to loop through and display the data for the other three weeks below in subsequent rows...

    can anyone here see anything obviously wrong with the code below.....

    Many thanks for your help

    Andy


    <%
    do while NOT rsCalender.EOF
    numberofDay = 2
    %>
    <TR>
    <% while numberofDay < 8 %>
    <TD><%
    if datepart("w",rsCalender("wages_calc1_Date") ) = numberofDay Then
    response.write rsCalender("wages_calc1_type") & " <BR> "
    response.write rsCalender("job_name")
    response.write rsCalender("wages_calc1_Date")
    rsCalender.MoveNext
    else
    response.write "-"
    end if
    %>
    </td>
    <%
    numberofDay = numberofDay + 1
    wend %>
    <TD>
    <%
    if datepart("w", rsCalender("wages_calc1_Date")) = 1 Then
    response.write rsCalender("wages_calc1_type") & " <BR> "
    response.write rsCalender("job_name")
    rsCalender.MoveNext
    else
    response.write "-"
    end if
    %>
    </td>
    </tr>
    <% loop %>
    </table>

































  • 14 years ago

    You are moving record in the while loop.

    You should exit the while loop instead of   Movenext.

    If not you have to check end of record before using the movenext.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe