Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why do these 2 pieces of code produce different outputs?

Status
Not open for further replies.

JGKWORK

IS-IT--Management
Apr 1, 2003
342
GB
Hi,

can someone please tell me why code No1 pulls ALL 7 records from my table but code No2 only pulls 3 (seemingly random) records?

No1/:

'Image drop down menu taken from
SQL2 = "SELECT * FROM News_Article_Pictures ORDER BY Picture_Title Asc"
Set RS2 = Connection.Execute(SQL2)

Do while not RS2.eof
Response.write &quot;<option Value='&quot; & RS2(&quot;PictureID&quot;) & &quot;'>&quot; & RS2(&quot;Picture_Title&quot;)
RS2.Movenext
Loop

RS2.close
Set RS2=nothing



No2/:

'Image drop down menu taken from
SQL2 = &quot;SELECT * FROM News_Article_Pictures ORDER BY Picture_Title Asc&quot;
Set RS2 = Connection.Execute(SQL2)

Do while not RS2.eof %>

<option Value=&quot;<%=RS2(&quot;PictureID&quot;)%>><%=RS(&quot;Picture_Title&quot;)%></option>
<%
RS2.Movenext
Loop

RS2.close
Set RS2=nothing


Many thanks...
 
try to response.write a &quot;<select>&quot; before and a &quot;</select>&quot; after the loop

hth,
Foxbox
 
You are missing a double quote mark after your first <%= %> grouping, between the >>.

Should be:

<option Value=&quot;<%=RS2(&quot;PictureID&quot;)%>&quot;><%=RS(&quot;Picture_Title&quot;)%></option>

Michael
 
damn missed that, will go and give those a whirl, thanks alot...
 
Also, something to keep in mind that doesn't directly affect this:
Any time you pull back a recordset (especially if your asking for an Order By) you should try to do a MoveFirst on the recordset before doing anything else witht he data. Occasionally when you reorder the recordset will come back with the pointer somewhere in the middle instead of pointing to the top record. The MoveFirst can be pretty easily applied simply by doing:
Code:
If Not rs.EOF Then rs.MoveFirst
directly after your .Execute(sqlstring) line.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top