.NETGURU
Datareader.Read() & EOF
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdata' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Kristian
-- Moved from [aspngfreeforall] to [aspngdata] by Tony Stark <Click here to reveal e-mail address> --

Hi

From what i can gather
-----------------------------
While myReader.Read()
'do stuff
End While
-----------------------------

Is fine for looping through a datareader. But unlike what ive read in past
messages.

-----------------------------
If Not myReader.Read() Then
'End off file
Else
    'Do something
End If
-----------------------------

Is not a suitable replacment for classic ASPs

-----------------------------
IF recordset.EOF Then
'End of file
Else
    'Do something
End If
-----------------------------

Can anyone tell me what is? Or if Read() is the way to go, exactly in what
context to use it for checking for EOFs

Thanks

Kris

Reply to this message...
 
    
Kristian
-- Moved from [aspngfreeforall] to [aspngdata] by Tony Stark <Click here to reveal e-mail address> --

Sorry. My reason for it not being suitable was that it seems to advance
forward 1 record. So when i am ready to start looping it misses the first
record of the datareader.

Kris

Reply to this message...
 
    
dave wanta (VIP)
Hi Kristian,

i believe this should handle it

if ( dr.Read() ){

do{
Console.Writeline( dr[0].ToString() );
}while(dr.read() )
}

dave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.123aspx.com
The Largest ASP.NET Web Directory!
Find the latest ASP.NET resources --
Subscribe to our newsletter!
----- Original Message -----
From: "Kristian" <Click here to reveal e-mail address>
To: "aspngdata" <Click here to reveal e-mail address>
Sent: Monday, June 17, 2002 10:51 AM
Subject: [aspngdata] Datareader.Read() & EOF

> -- Moved from [aspngfreeforall] to [aspngdata] by Tony Stark
<Click here to reveal e-mail address> --
[Original message clipped]

Reply to this message...
 
    
Kristian
The code below was how i was using it. Heres my code

-----------------------------
if dr.Read() Then
    Repeater.DataSource = dr
Else
    Repeater.Visible = False
End If
Repeater.DataBind()
dr.Close
dr = Nothing
-----------------------------

What im trying to achieve is if the datareader contained no data then hide
the repeater.
The problem with the above code is that when i bind the data it is missing
the first record. so calling the dr.read() is pushing forward a record. Is
there a way to test for a record without pushing forward 1 record. Or is the
only way of achiving this through the use of a dataset. In which case i can
see no use for a datareader if it cant check itself for data present.

Thanks

Kristian

Hi Kristian,

i believe this should handle it

if ( dr.Read() ){

do{
Console.Writeline( dr[0].ToString() );
}while(dr.read() )
}

dave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.123aspx.com
The Largest ASP.NET Web Directory!
Find the latest ASP.NET resources --
Subscribe to our newsletter!
----- Original Message -----
From: "Kristian" <Click here to reveal e-mail address>
To: "aspngdata" <Click here to reveal e-mail address>
Sent: Monday, June 17, 2002 10:51 AM
Subject: [aspngdata] Datareader.Read() & EOF

> -- Moved from [aspngfreeforall] to [aspngdata] by Tony Stark
<Click here to reveal e-mail address> --
[Original message clipped]

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Remas Wojciechowski
Kristian,

haven't tested it, but how about:
Repeater.DataSource = dr
Repeater.DataBind()
if (Repeater.Items.Count == 0) Repeater.Visible = false;
(or even cooler: Repeater.Visible = !(Repeater.Items.Count == 0)

hth
Remas
http://www.aspalliance.com/remas

----- Original Message -----
From: "Kristian" <Click here to reveal e-mail address>
To: "aspngdata" <Click here to reveal e-mail address>
Sent: Wednesday, June 19, 2002 2:29 PM
Subject: [aspngdata] Re: Datareader.Read() & EOF

[Original message clipped]

Reply to this message...
 
    
Kristian
That worked, thanks a lot, I tried something like that early on but
obviously cocked it up.

Do you know the VB equivilent of

Repeater.Visible = !(Repeater.Items.Count == 0)

Looks like a cleaner way of coding but i couldnt find any mention in the
operators list.

Kristian
Click here to reveal e-mail address
http://www.BangingTunes.com

-----Original Message-----
From: Remas Wojciechowski [mailto:Click here to reveal e-mail address]
Sent: 19 June 2002 13:48
To: aspngdata
Subject: [aspngdata] Re: Datareader.Read() & EOF

Kristian,

haven't tested it, but how about:
Repeater.DataSource = dr
Repeater.DataBind()
if (Repeater.Items.Count == 0) Repeater.Visible = false;
(or even cooler: Repeater.Visible = !(Repeater.Items.Count == 0)

hth
Remas
http://www.aspalliance.com/remas

----- Original Message -----
From: "Kristian" <Click here to reveal e-mail address>
To: "aspngdata" <Click here to reveal e-mail address>
Sent: Wednesday, June 19, 2002 2:29 PM
Subject: [aspngdata] Re: Datareader.Read() & EOF

[Original message clipped]

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Curtis Swartzentruber
Repeater.Visible = NOT (Repeater.Items.Count = 0)
[Original message clipped]

Reply to this message...
 
    
ricky_aish B
(Type your message here)
hey try this for getting value..
its just like ASP recordset

*****************
**************
While oReader.Read()
If oReader("poption") = 1 Then
opt1 = opt1 + 1
ElseIf oReader("poption") = 2 Then
opt2 = opt2 + 1
Else
opt3 = opt3 + 1
End If
End While

***************
*************

--------------------------------
From: ricky_aish B
Reply to this message...
 
 
System.Console
System.Web.UI.WebControls.Repeater




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification