Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Simple loop code bombing


Message #1 by Spencer <spencer@m...> on Thu, 20 Dec 2001 15:11:53 -0500
Hello,



I don't understand why but I have a simple DO WHILE NOT loop to display a RS

but it seems to always error when I run out of records. Can't figure out

why/. 



Any help to point out some blatant mistake would be appreciated.



CODE:

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

SQL="SELECT * FROM artists WHERE show_id="& request.querystring("show_id")

&" ORDER BY ID ASC"

set getart=Server.createobject("ADODB.RECORDSET")

getart.CursorLocation = 3

getart.open SQL, conn

varcount=getart.recordcount





getart.movefirst



'populate the fields with the names by looping through the recordset





Do While NOT getart.EOF



%>



<tr><td><input type='text' name="fname" value="<% response.write

getart("artist_fname") %>"></td>

<td><input type='text' name="lname" value="<% response.write

getart("artist_lname") %>"></td>

<td><input type='text' name="medium" value="<% response.write

getart("medium") %>"></td>

<td><input type="text" name="origin" value="<% response.write

getart("origin") %>">

<input type='hidden' name="artist_id" value="<% response.write getart("ID")

%>"></td>

</tr>

<%



if not getart.eof then

getart.movenext

else

exit do

end if

loop





=============



ERROR MESSAGE:



ADODB.Field error '80020009'



Either BOF or EOF is True, or the current record has been deleted. Requested

operation requires a current record.



/mercer_form2_temp.asp, line 0







TIA



~spencer~



Message #2 by Brooks_Piggott@D... on Thu, 20 Dec 2001 14:28:39 -0600
Make sure you don't have a .EOF condition when you do your initial

getart.movefirst



Regards,

Brooks Piggott

Dell Computer Corp.



-----Original Message-----

From: Spencer [mailto:spencer@m...]

Sent: Thursday, December 20, 2001 2:12 PM

To: Access ASP

Subject: [access_asp] Simple loop code bombing





Hello,



I don't understand why but I have a simple DO WHILE NOT loop to display a RS

but it seems to always error when I run out of records. Can't figure out

why/. 



Any help to point out some blatant mistake would be appreciated.



CODE:

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

SQL="SELECT * FROM artists WHERE show_id="& request.querystring("show_id")

&" ORDER BY ID ASC"

set getart=Server.createobject("ADODB.RECORDSET")

getart.CursorLocation = 3

getart.open SQL, conn

varcount=getart.recordcount





getart.movefirst



'populate the fields with the names by looping through the recordset





Do While NOT getart.EOF



%>



<tr><td><input type='text' name="fname" value="<% response.write

getart("artist_fname") %>"></td>

<td><input type='text' name="lname" value="<% response.write

getart("artist_lname") %>"></td>

<td><input type='text' name="medium" value="<% response.write

getart("medium") %>"></td>

<td><input type="text" name="origin" value="<% response.write

getart("origin") %>">

<input type='hidden' name="artist_id" value="<% response.write getart("ID")

%>"></td>

</tr>

<%



if not getart.eof then

getart.movenext

else

exit do

end if

loop





=============



ERROR MESSAGE:



ADODB.Field error '80020009'



Either BOF or EOF is True, or the current record has been deleted. Requested

operation requires a current record.



/mercer_form2_temp.asp, line 0







TIA



~spencer~








Message #3 by Spencer <spencer@m...> on Thu, 20 Dec 2001 15:39:26 -0500
hey brook, 



I don't have any EOF condition before the .movefirst- and it displays all

the records it's just that I get the error  when it runs out of records.



-spencer-



on 12/20/01 3:28 PM, Brooks_Piggott@D... at Brooks_Piggott@D...

wrote:



> Make sure you don't have a .EOF condition when you do your initial

> getart.movefirst

> 

> Regards,

> Brooks Piggott

> Dell Computer Corp.

> 

> -----Original Message-----

> From: Spencer [mailto:spencer@m...]

> Sent: Thursday, December 20, 2001 2:12 PM

> To: Access ASP

> Subject: [access_asp] Simple loop code bombing

> 

> 

> Hello,

> 

> I don't understand why but I have a simple DO WHILE NOT loop to display a RS

> but it seems to always error when I run out of records. Can't figure out

> why/. 

> 

> Any help to point out some blatant mistake would be appreciated.

> 

> CODE:

> ------------------

> SQL="SELECT * FROM artists WHERE show_id="& request.querystring("show_id")

> &" ORDER BY ID ASC"

> set getart=Server.createobject("ADODB.RECORDSET")

> getart.CursorLocation = 3

> getart.open SQL, conn

> varcount=getart.recordcount

> 

> 

> getart.movefirst

> 

> 'populate the fields with the names by looping through the recordset

> 

> 

> Do While NOT getart.EOF

> 

> %>

> 

> <tr><td><input type='text' name="fname" value="<% response.write

> getart("artist_fname") %>"></td>

> <td><input type='text' name="lname" value="<% response.write

> getart("artist_lname") %>"></td>

> <td><input type='text' name="medium" value="<% response.write

> getart("medium") %>"></td>

> <td><input type="text" name="origin" value="<% response.write

> getart("origin") %>">

> <input type='hidden' name="artist_id" value="<% response.write getart("ID")

> %>"></td>

> </tr>

> <%

> 

> if not getart.eof then

> getart.movenext

> else

> exit do

> end if

> loop

> 

> 

> =============

> 

> ERROR MESSAGE:

> 

> ADODB.Field error '80020009'

> 

> Either BOF or EOF is True, or the current record has been deleted. Requested

> operation requires a current record.

> 

> /mercer_form2_temp.asp, line 0

> 

> 

> 

> TIA

> 

> ~spencer~

> 

> 




> 






Message #4 by "Scott Reed" <scottr@m...> on Thu, 20 Dec 2001 16:18:14 -0600

'I usually make sure I have a record first....



If Not getart.EOF And Not getart.BOF Then





getart.movefirst



Dim sCurrentArtist

sCurrentArtist = SQL(show_id).Value



		'Start your While Loop

While Not getart.EOF



		'Set a condition to exit loop

If sCurrentArtist = "" Then

	Your Done

		'if that condition is not met, do something

If sCurrentArist <> "" Then



	Do something.



		'increment to next record

	SQL.MoveNext

	sCurrentArtist = SQL("show_id").Value



		'close conditional statments and loop

End If(s)



Wend



-----Original Message-----

From: Spencer [mailto:spencer@m...]

Sent: Thursday, December 20, 2001 2:39 PM

To: Access ASP

Subject: [access_asp] RE: Simple loop code bombing





hey brook,



I don't have any EOF condition before the .movefirst- and it displays all

the records it's just that I get the error  when it runs out of records.



-spencer-



on 12/20/01 3:28 PM, Brooks_Piggott@D... at Brooks_Piggott@D...

wrote:



> Make sure you don't have a .EOF condition when you do your initial

> getart.movefirst

>

> Regards,

> Brooks Piggott

> Dell Computer Corp.

>

> -----Original Message-----

> From: Spencer [mailto:spencer@m...]

> Sent: Thursday, December 20, 2001 2:12 PM

> To: Access ASP

> Subject: [access_asp] Simple loop code bombing

>

>

> Hello,

>

> I don't understand why but I have a simple DO WHILE NOT loop to display a

RS

> but it seems to always error when I run out of records. Can't figure out

> why/.

>

> Any help to point out some blatant mistake would be appreciated.

>

> CODE:

> ------------------

> SQL="SELECT * FROM artists WHERE show_id="& request.querystring("show_id")

> &" ORDER BY ID ASC"

> set getart=Server.createobject("ADODB.RECORDSET")

> getart.CursorLocation = 3

> getart.open SQL, conn

> varcount=getart.recordcount

>

>

> getart.movefirst

>

> 'populate the fields with the names by looping through the recordset

>

>

> Do While NOT getart.EOF

>

> %>

>

> <tr><td><input type='text' name="fname" value="<% response.write

> getart("artist_fname") %>"></td>

> <td><input type='text' name="lname" value="<% response.write

> getart("artist_lname") %>"></td>

> <td><input type='text' name="medium" value="<% response.write

> getart("medium") %>"></td>

> <td><input type="text" name="origin" value="<% response.write

> getart("origin") %>">

> <input type='hidden' name="artist_id" value="<% response.write

getart("ID")

> %>"></td>

> </tr>

> <%

>

> if not getart.eof then

> getart.movenext

> else

> exit do

> end if

> loop

>

>

> =============

>

> ERROR MESSAGE:

>

> ADODB.Field error '80020009'

>

> Either BOF or EOF is True, or the current record has been deleted.

Requested

> operation requires a current record.

>

> /mercer_form2_temp.asp, line 0

>

>

>

> TIA

>

> ~spencer~

>

>




$subst('Email.Unsub').

>




$subst('Email.Unsub').










Message #5 by Spencer <spencer@m...> on Thu, 20 Dec 2001 17:41:57 -0500
Scott- dumbass question but what's the syntax editing a While loop? It's not

'exit do' or 'exit while' - so what is it.



And I'm not very clear on the difference of a WHILE loop as opposed to a DO

WHILE loop. When should I be using which?



Thanks again.



Spencer





 on 12/20/01 5:18 PM, Scott Reed at scottr@m... wrote:



> 

> 'I usually make sure I have a record first....

> 

> If Not getart.EOF And Not getart.BOF Then

> 

> 

> getart.movefirst

> 

> Dim sCurrentArtist

> sCurrentArtist = SQL(show_id).Value

> 

> 'Start your While Loop

> While Not getart.EOF

> 

> 'Set a condition to exit loop

> If sCurrentArtist = "" Then

> Your Done

> 'if that condition is not met, do something

> If sCurrentArist <> "" Then

> 

> Do something.

> 

> 'increment to next record

> SQL.MoveNext

> sCurrentArtist = SQL("show_id").Value

> 

> 'close conditional statments and loop

> End If(s)

> 

> Wend

> 

> -----Original Message-----

> From: Spencer [mailto:spencer@m...]

> Sent: Thursday, December 20, 2001 2:39 PM

> To: Access ASP

> Subject: [access_asp] RE: Simple loop code bombing

> 

> 

> hey brook,

> 

> I don't have any EOF condition before the .movefirst- and it displays all

> the records it's just that I get the error  when it runs out of records.

> 

> -spencer-

> 

> on 12/20/01 3:28 PM, Brooks_Piggott@D... at Brooks_Piggott@D...

> wrote:

> 

>> Make sure you don't have a .EOF condition when you do your initial

>> getart.movefirst

>> 

>> Regards,

>> Brooks Piggott

>> Dell Computer Corp.

>> 

>> -----Original Message-----

>> From: Spencer [mailto:spencer@m...]

>> Sent: Thursday, December 20, 2001 2:12 PM

>> To: Access ASP

>> Subject: [access_asp] Simple loop code bombing

>> 

>> 

>> Hello,

>> 

>> I don't understand why but I have a simple DO WHILE NOT loop to display a

> RS

>> but it seems to always error when I run out of records. Can't figure out

>> why/.

>> 

>> Any help to point out some blatant mistake would be appreciated.

>> 

>> CODE:

>> ------------------

>> SQL="SELECT * FROM artists WHERE show_id="& request.querystring("show_id")

>> &" ORDER BY ID ASC"

>> set getart=Server.createobject("ADODB.RECORDSET")

>> getart.CursorLocation = 3

>> getart.open SQL, conn

>> varcount=getart.recordcount

>> 

>> 

>> getart.movefirst

>> 

>> 'populate the fields with the names by looping through the recordset

>> 

>> 

>> Do While NOT getart.EOF

>> 

>> %>

>> 

>> <tr><td><input type='text' name="fname" value="<% response.write

>> getart("artist_fname") %>"></td>

>> <td><input type='text' name="lname" value="<% response.write

>> getart("artist_lname") %>"></td>

>> <td><input type='text' name="medium" value="<% response.write

>> getart("medium") %>"></td>

>> <td><input type="text" name="origin" value="<% response.write

>> getart("origin") %>">

>> <input type='hidden' name="artist_id" value="<% response.write

> getart("ID")

>> %>"></td>

>> </tr>

>> <%

>> 

>> if not getart.eof then

>> getart.movenext

>> else

>> exit do

>> end if

>> loop

>> 

>> 

>> =============

>> 

>> ERROR MESSAGE:

>> 

>> ADODB.Field error '80020009'

>> 

>> Either BOF or EOF is True, or the current record has been deleted.

> Requested

>> operation requires a current record.

>> 

>> /mercer_form2_temp.asp, line 0

>> 

>> 

>> 

>> TIA

>> 

>> ~spencer~

>> 

>> 




> $subst('Email.Unsub').

>> 




> $subst('Email.Unsub').

> 

> 




> 

> 






Message #6 by "Ken Schaefer" <ken@a...> on Fri, 21 Dec 2001 12:26:16 +1100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Spencer" <spencer@m...>

Subject: [access_asp] RE: Simple loop code bombing





: Scott- dumbass question but what's the syntax editing a While loop? It's

not

: 'exit do' or 'exit while' - so what is it?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Look in the docs - there isn't one.

http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: And I'm not very clear on the difference of a WHILE loop as opposed to a

DO

: WHILE loop. When should I be using which?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Again, the docs provide helpful advice on this matter.

You shouldn't need an exit statement when iterating a recordset:



<%

If not objRS.EOF then



    Do While Not objRS.EOF



        ' Write out records here

        objRS.Movenext



    Loop



Else



     Response.Write("<p>No records.</p>" & vbCrLf)



End If

%>



Cheers

Ken



Message #7 by "Scott Reed" <scottr@m...> on Fri, 21 Dec 2001 09:36:38 -0600
Do While (Not)

...

Wend



-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Thursday, December 20, 2001 7:26 PM

To: Access ASP

Subject: [access_asp] RE: Simple loop code bombing





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Spencer" <spencer@m...>

Subject: [access_asp] RE: Simple loop code bombing





: Scott- dumbass question but what's the syntax editing a While loop? It's

not

: 'exit do' or 'exit while' - so what is it?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Look in the docs - there isn't one.

http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: And I'm not very clear on the difference of a WHILE loop as opposed to a

DO

: WHILE loop. When should I be using which?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Again, the docs provide helpful advice on this matter.

You shouldn't need an exit statement when iterating a recordset:



<%

If not objRS.EOF then



    Do While Not objRS.EOF



        ' Write out records here

        objRS.Movenext



    Loop



Else



     Response.Write("<p>No records.</p>" & vbCrLf)



End If

%>



Cheers

Ken








Message #8 by "Scott Reed" <scottr@m...> on Fri, 21 Dec 2001 10:07:18 -0600
IMHO, the difference is in personal preference.



"While" is a little more generic and says that

"while this condition is present, this(these) other condition(s) are

present"

I use it for things like Error Handling.



While Tom is logged in, background color = red

Wend



"Do While" is more of an explicit loop and says that

"Do this while this(these) other condition(s) are present"



Do While Tom is logged in

Loop



Anyhow, I'm sure it doesn't matter.



Scott



-----Original Message-----

From: Spencer [mailto:spencer@m...]

Sent: Thursday, December 20, 2001 4:42 PM

To: Access ASP

Subject: [access_asp] RE: Simple loop code bombing





Scott- dumbass question but what's the syntax editing a While loop? It's not

'exit do' or 'exit while' - so what is it.



And I'm not very clear on the difference of a WHILE loop as opposed to a DO

WHILE loop. When should I be using which?



Thanks again.



Spencer





 on 12/20/01 5:18 PM, Scott Reed at scottr@m... wrote:



>

> 'I usually make sure I have a record first....

>

> If Not getart.EOF And Not getart.BOF Then

>

>

> getart.movefirst

>

> Dim sCurrentArtist

> sCurrentArtist = SQL(show_id).Value

>

> 'Start your While Loop

> While Not getart.EOF

>

> 'Set a condition to exit loop

> If sCurrentArtist = "" Then

> Your Done

> 'if that condition is not met, do something

> If sCurrentArist <> "" Then

>

> Do something.

>

> 'increment to next record

> SQL.MoveNext

> sCurrentArtist = SQL("show_id").Value

>

> 'close conditional statments and loop

> End If(s)

>

> Wend

>

> -----Original Message-----

> From: Spencer [mailto:spencer@m...]

> Sent: Thursday, December 20, 2001 2:39 PM

> To: Access ASP

> Subject: [access_asp] RE: Simple loop code bombing

>

>

> hey brook,

>

> I don't have any EOF condition before the .movefirst- and it displays all

> the records it's just that I get the error  when it runs out of records.

>

> -spencer-

>

> on 12/20/01 3:28 PM, Brooks_Piggott@D... at Brooks_Piggott@D...

> wrote:

>

>> Make sure you don't have a .EOF condition when you do your initial

>> getart.movefirst

>>

>> Regards,

>> Brooks Piggott

>> Dell Computer Corp.

>>

>> -----Original Message-----

>> From: Spencer [mailto:spencer@m...]

>> Sent: Thursday, December 20, 2001 2:12 PM

>> To: Access ASP

>> Subject: [access_asp] Simple loop code bombing

>>

>>

>> Hello,

>>

>> I don't understand why but I have a simple DO WHILE NOT loop to display a

> RS

>> but it seems to always error when I run out of records. Can't figure out

>> why/.

>>

>> Any help to point out some blatant mistake would be appreciated.

>>

>> CODE:

>> ------------------

>> SQL="SELECT * FROM artists WHERE show_id="&

request.querystring("show_id")

>> &" ORDER BY ID ASC"

>> set getart=Server.createobject("ADODB.RECORDSET")

>> getart.CursorLocation = 3

>> getart.open SQL, conn

>> varcount=getart.recordcount

>>

>>

>> getart.movefirst

>>

>> 'populate the fields with the names by looping through the recordset

>>

>>

>> Do While NOT getart.EOF

>>

>> %>

>>

>> <tr><td><input type='text' name="fname" value="<% response.write

>> getart("artist_fname") %>"></td>

>> <td><input type='text' name="lname" value="<% response.write

>> getart("artist_lname") %>"></td>

>> <td><input type='text' name="medium" value="<% response.write

>> getart("medium") %>"></td>

>> <td><input type="text" name="origin" value="<% response.write

>> getart("origin") %>">

>> <input type='hidden' name="artist_id" value="<% response.write

> getart("ID")

>> %>"></td>

>> </tr>

>> <%

>>

>> if not getart.eof then

>> getart.movenext

>> else

>> exit do

>> end if

>> loop

>>

>>

>> =============

>>

>> ERROR MESSAGE:

>>

>> ADODB.Field error '80020009'

>>

>> Either BOF or EOF is True, or the current record has been deleted.

> Requested

>> operation requires a current record.

>>

>> /mercer_form2_temp.asp, line 0

>>

>>

>>

>> TIA

>>

>> ~spencer~

>>

>>




> $subst('Email.Unsub').

>>




> $subst('Email.Unsub').

>

>




$subst('Email.Unsub').

>

>




$subst('Email.Unsub').











  Return to Index