hello
I have a datareader and I how can i know that, how many row this datareader have?
string query_ci = "SELECT [Kolon1],[Kolon2],[Kolon3] FROM[Sheet6$A:J] WHERE [Kolon1]='" + kolon_bul+ "'";
OleDbDataReader rdr_ci;
OleDbCommand komut_ci = new OleDbCommand(query_ci, conn);
rdr_ci = komut_ci.ExecuteReader();
---> i want to know in here rows this "rdr_ci" have?
while (rdr_ci.Read())
{
---> or in here, i want to know in here how many times this "while" count in the first loop?
OleDbCommand komut = new
OleDbCommand("UPDATE [Sheet6$] SET [Cat]='OK' WHERE [Sira]='" + rdr_ci["Sira"] + "' ", baglanti);
komut.ExecuteNonQuery();
}
Loading

Suthish NairRank #92 · 22.8K reputationPosted Nov 5, 2010, 4:34 AM EDT
not known until all the records have been read. You need to read all the records and keep track of count yourself.
Or as i listed above, use any of logics.
Or.. try..
DataTable dt = new DataTable();
dt.Load(rdr_ci);
dt.Tables[0].Rows.Count will gives the count..
Suthish NairRank #92 · 22.8K reputationPosted Nov 5, 2010, 4:14 AM EDT
1. use two select queries, for count (ExecuteScalar) rows..
2. use Dataset logic
3. or from the same logic your using. you will get value from object "a".
oops you edited the post..
int a = 0;
check for HasRows
while loop
a++; ==> will gives number of rows..
yokzuRank #5,421 · 300 reputationPosted Nov 5, 2010, 4:20 AM EDT
JureRank #2,128 · 670 reputationPosted Nov 5, 2010, 4:57 AM EDT
SELECT COUNT(*) AS NumOfRows FROM your_table
This will return single row with column named "NumOfRows". So now you just have to read the value from that single cell.