Check for rows in DataReader (CF 1.0)

  • Thread starter Thread starter Sascha
  • Start date Start date
S

Sascha

Hi there,

I've tried several ways to resolve this problem and also searched the
net but I'm still not satisfied with my different solutions:

how do I check for rows in a DataReader in a CompactFramework Appication
with SQL Server CE?
I tried something like
Code:
sqlSCom.CommandText = "SELECT somerows FROM sometable"
sqlSReader = sqlSCom.ExecuteReader
'Check if one row can be read from the reader
IF sqlSReader.Read THEN
.... 'read in a loop
.... do something
.... WHILE sqlSReader.Read
....... do something
.... END WHILE
END IF
and also checked for DBNull values in my IF-clause ("IF sqlSReader.Read
AND sqlSReader(0).isDBNull = false THEN") but this didn't work in all
situations.
Would someone have a great solution to this (perhaps a handwritten
function that could do the trick) or some thread or tutorial?
Thanks in advance!

Sascha ([email protected])
 
Sascha:

What is the purpose of the extra if statement before the while.

bool hasRows = false
while(rdr.Reader()){
//whatever code

hasRows = true;
}

if (hasRows){

}
else{

}
 
Back
Top