Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: equivilent of RS.EOF


Message #1 by "Pat Hastings" <pat.hastings@s...> on Wed, 3 Apr 2002 15:33:18 +0100
How do you properly test for no data being returned in a datareader?

I mean with ado you could test a recordset with something like "if 
rs.eof then ..." but whats the .net equivilent then?

Pat
Message #2 by "Wayne Ayotte" <ayottew@s...> on Wed, 3 Apr 2002 11:01:06 -0500
As I recall, the obgReader.read() function returns an end of file
indication: i.e.

While myReader.read()
    do something
End While


see help under - net framework SDK documentation:
.net framework sdk/.NET framework reference/class
library/System.Data.OleDb/OleDbDataReader Class/Methods/Read


----- Original Message -----
From: "Pat Hastings" <pat.hastings@s...>
To: "ADO.NET" <ado_dotnet@p...>
Sent: Wednesday, April 03, 2002 9:33 AM
Subject: [ado_dotnet] equivilent of RS.EOF


How do you properly test for no data being returned in a datareader?

I mean with ado you could test a recordset with something like "if rs.eof
then ..." but whats the .net equivilent then?

Pat



Message #3 by "greg robinson" <grobinson@d...> on Thu, 4 Apr 2002 02:01:12
Why not just check Read for True or False? 

How do you properly test for no data being returned in a datareader?

I mean with ado you could test a recordset with something like "if 
rs.eof then ..." but whats the .net equivilent then?

Pat
Message #4 by "tariq" <tariqs79@h...> on Mon, 8 Apr 2002 15:08:16
try this :

rs=cmd.executedatareader()
if IsDBNull(rs) then
  response.write ("no data there")
else
 do somthing
end if
Message #5 by "Steve Brownell" <sbrownell@a...> on Mon, 8 Apr 2002 12:23:39 -0400
Microsoft designed the DataReader to overcome what they perceived as the
most common mistake by programmers... namely the tendancy to forget to
use a MoveNext method in a while loop.  Therefore They made the .Read()
method of the datareader do several things at once. 

First it checks to see if there really is a row to retrieve or not.  If
not, it returns false.  Subsequent calls to .Read() retrieves the next
row if there is one to retrieve. 

So the normal old construct would be...
While not RS.EOF
    'do something
    RS.MoveNext
Wend

If no records existed in RS then the loop is skipped entirely.

The new construct is...
While DR.Read()
    'do something
Wend

Again if no records exist in the DR, then the loop is skipped entirely.
Also, the Read() method increments to the next record in the DataReader
everytime through the loop.



Steve Brownell
AllMeds, Inc.

-----Original Message-----
From: Pat Hastings [mailto:pat.hastings@s...]
Sent: Wednesday, April 03, 2002 9:33 AM
To: ADO.NET
Subject: [ado_dotnet] equivilent of RS.EOF


How do you properly test for no data being returned in a datareader?

I mean with ado you could test a recordset with something like "if
rs.eof then ..." but whats the .net equivilent then?

Pat


  Return to Index