I am afraid you have stumbled on a Firebird
limitation. As stated in following Firebird FAQ link:
Why FbDataReader.HasRows returns always true?
The FbDataReader.HasRows property is implemented for compatibility only. It returns always true because Firebird doesn't have a way for know if a query returns rows of not without fetching the data.
There is already a mention of this in the Firebird Tracker
. Check the issue DNET-305.
On the other hand, in .NET, it seems OleDbDataReader
and SqlDataReader
, which inherit from DbDataReader
have the same problem, as stated in this MSDN link.
Since FbDataReader
inherits from the same class as those, you might want to consider one of the workarounds that Microsoft suggests in its MSDN article, which is to perform first a select count(*)
. Granted, that is unelegant and a waste of time and resources but at least it could help you out.