Issue Details (XML | Word | Printable)

Key: DNET-305
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Jiri Cincura
Reporter: Steven Harris
Votes: 0
Watchers: 3

If you were logged in you would be able to see more operations.
.NET Data provider

Problem with HasRows on FbDataReader

Created: 05/Apr/10 09:33 PM   Updated: 23/Jul/18 06:34 AM
Component/s: ADO.NET Provider
Affects Version/s: 2.5.1
Fix Version/s: None

Environment: XP Pro, FB ODS structure 11.1, Dialect 3, Firebird ADO.NET Driver

 Description  « Hide
Should the HasRows property return true if a datareader has no rows?

I can execute a query such as "select cus_id, cus_code, cus_name from customer where cus_id = -1" and although there is no row with a cus_id of -1, the HasRows property returns true.

Of course, when I do the dr.Read() and then dr.GetString(1) an exception occurs:
"There are no data to read"

I thought the HasRows property should indicate if there are rows to be read. Otherwise the only way I can use it is to set up a try / catch structure which seems incorrect.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Steven Harris added a comment - 05/Apr/10 09:44 PM
I notice that the dr.Read() function returns true or false correctly.
In other words, I can use something like if (dr.Read()) or while dr.Read()

However, according to MSDN documentation on HasRows::

Gets a value that indicates whether the DataTableReader contains one or more rows.

Also it says...
Use the HasRows property to avoid the requirement to call the Read method of the DataTableReader if there are no rows within the current result set.

Taken From:

Jiri Cincura added a comment - 06/Apr/10 07:17 AM
Firebird protocol has no support for this. Until you actually ask for some data. Hence the property returns true for all selects.

Ruslan Valishin added a comment - 20/Jul/18 04:58 PM
Why do not cache first row in FbDataReader.HasRows property to make it work as intended in API?

Jiri Cincura added a comment - 23/Jul/18 06:34 AM
Then you still don't know whether there's more.