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

Better exception message for MySqlConnection misuse #565

Closed
bgrainger opened this issue Sep 29, 2018 · 2 comments
Closed

Better exception message for MySqlConnection misuse #565

bgrainger opened this issue Sep 29, 2018 · 2 comments

Comments

@bgrainger
Copy link
Member

bgrainger commented Sep 29, 2018

Since MySqlConnector provides true async methods, some users want to invoke multiple "overlapped" operations, e.g., executing multiple ExecuteNonQueryAsync method calls simultaneously, e.g., #554, #560, #562.

This gives an error (probably inspired by Connector/NET): "There is already an open DataReader associated with this Connection which must be closed first."

While true, this doesn't help the user understand the problem. It's also confusing if the user is just calling ExecuteScalar and doesn't understand that a DataReader is being used behind the scenes: https://stackoverflow.com/questions/51854390/without-any-select-there-is-already-an-open-datareader-associated-with-this

We should create a documentation page that explains the problem, the two common forms of misuse (overlapping on the same thread, e.g., calling ExecuteNonQuery from within a while (reader.Read()) loop; multiple simultaneous async calls on different threads), and how to resolve the error. Then the exception message should be simplified ("Cannot start a second operation while this connection is in use"?) and have a link to that page.

@bgrainger
Copy link
Member Author

bgrainger commented Sep 29, 2018

Implemented in 0.45.1.

@bgrainger
Copy link
Member Author

bgrainger commented Oct 1, 2018

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

No branches or pull requests

1 participant