ASP.NET Datareader EOF Equivalent to ASP Recordset

Joined
Apr 5, 2007
Messages
3
Reaction score
0
Here's the code I'm running:

if oRS2.Read() then
Response.write("<B>Show schedule for dates:</b> ")
%>

<select name="ddlist" onClick= " = '' + this.options[this.selectedIndex ].value;">

<%
While oRS2.Read()
Response.Write("<option value=" & oRS2("scheduleid") & ">" & FormatDateTime(oRS2("datefrom"),1) & " - " & FormatDateTime(oRS2("dateto"),1) & "</option>")
End While
end if
Response.Write("</select>")
%>

This code works, however it eliminates the first record with the "if oRS2.Read() then" line. How can I determine if a reader holds any records without moving the reader to the next record?
 
Joined
Apr 5, 2007
Messages
3
Reaction score
0
solved that problem, but have a new problem....

Ok I found out about the Datareader.HasRows property, but now I have a new problem with the following code:

if oRS.HasRows then
Session("listvalue") = oRS("scheduleid")
End if

There is a row that is returned, but trying to set the variable to the row item returns a "System.InvalidOperationException: Invalid attempt to read when no data is present." error. Previously I had it set up as the following:

if oRS.Read() then
Session("listvalue") = oRS("scheduleid")
End if

This code does not error, but skips right past the one record that was returned, so I can't win....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top