Answer the question
In order to leave comments, you need to log in
Oracle in C#: how to get the number of selected rows?
First I do this:
OracleCommand command = ...;
OracleDataReader reader = command.ExecuteReader();
long rowsCount = reader.FetchSize;
Answer the question
In order to leave comments, you need to log in
ExecuteReader(), which returns an OracleDataReader, is designed to sequentially read the results of a query. In the course of work, he does not know how much more data will be. Moreover, the data in the Reader may begin to arrive when the request has not yet been completed on the server.
To get the number of rows, you either need to read all records from the OracleDataReader in a loop. Or form a query like: "Select count(*) from " + command.CommandText. And call command.ExecuteScalar() for it. As a result, you will get the number of rows without passing them to the client.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question