S
S
sisharpacc2014-10-08 17:07:35
Oracle
sisharpacc, 2014-10-08 17:07:35

Oracle in C#: how to get the number of selected rows?

First I do this:

OracleCommand command = ...;
OracleDataReader reader = command.ExecuteReader();

Visual Studio prompted FetchSize:
long rowsCount = reader.FetchSize;
The problem is that FetchSize returns a value that is an order of magnitude larger than the actual number of fetched rows. It's strange that on MSDN there is no such field in the class description msdn.microsoft.com/ru-ru/library/vstudio/system.da...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2014-10-08
@sisharpacc

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 question

Ask a Question

731 491 924 answers to any question