Click here to Skip to main content
15,887,940 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the following code i want to find how many number of rows are affected by query and that dynamically assigned size to array rawData

What I have tried:

OleDbConnection con = (new DABasis()).getConnect();
         OleDbCommand cmd = con.CreateCommand();
         con.Open();
         cmd.CommandText = ("select * from KnowledgeTB");
         OleDbDataReader Reader = cmd.ExecuteReader();
         //if (Reader.HasRows)
         //    Reader.Read();
         int count= 0;
         count = Reader;
    //  int cnt = int.Parse(count);

         int[][] rawData = new int[count][];
         while (Reader.Read())
         {

             int db_data = Reader.GetInt32(3);
         //    rawData[i] = new int[] { i, db_data };
             rawData[i] = new int[] { i, db_data };
             i = i + 1;
         }


         cmd.Dispose();
         con.Close();
Posted
Updated 14-Apr-17 0:55am
Comments
[no name] 14-Apr-17 7:26am    
Worth to read: There is no RecordCount property when yo use the OleDbDataReader [^]

1 solution

None. SELECT operations do not affect any rows - they just return the data you specify.
In this case, it will return all rows and all columns for the KnowledgeTB table, so the number of rows in the table will tell you. But since you are using a OleDbDataReader you can't tell how many rows that is as the Read operation is asynchronous - it fetches each row one-by-one from the datasource when you call Read.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900