OracleDataReader objReader = cmd.ExecuteReader(); while(cmdReader.Read()) nRegisters++; objReader = cmd.ExecuteReader();
You must reinitialize this objReader, because this "pointer" remains in the last position when you want to read it again ... and there is no way to return to the first cursor position.
if you need the register number that you get, you should implement COUNT (*) in select instead of counting each line, you should be practical with your code:
if you need citizens of a certain city:
BEGIN OPEN REF_CUR FOR SELECT COUNT(*) AS nRegisters, City AS Var1, Country AS Var2 FROM Citizens WHERE City = 'City'; RETURN; END;
source share