Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with HasRows on FbDataReader [DNET305] #317

Closed
firebird-automations opened this issue Apr 6, 2010 · 7 comments
Closed

Problem with HasRows on FbDataReader [DNET305] #317

firebird-automations opened this issue Apr 6, 2010 · 7 comments

Comments

@firebird-automations
Copy link

Submitted by: Steven Harris (stevenharris)

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.

@firebird-automations
Copy link
Author

Commented by: Steven Harris (stevenharris)

Workaround:
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:
http://msdn.microsoft.com/en-us/library/system.data.datatablereader.hasrows.aspx

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Firebird protocol has no support for this. Until you actually ask for some data. Hence the property returns true for all selects.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Closed [ 6 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Author

Commented by: Ruslan Valishin (v0d01ey)

Hello!
Why do not cache first row in FbDataReader.HasRows property to make it work as intended in API?

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Then you still don't know whether there's more.

@firebird-automations
Copy link
Author

Commented by: bluish (bluish)

I agree that this method should be implemented.
Otherwise you should at least return a NotImplementedException to let us know we can't use it!

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Maybe better to throw NotSupportedException. Fine with me. But that would be a breaking change, hence would need to go to major version. Feel free to create a new item in tracker for that, if you feel like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants