Skip to content

Better exception message for MySqlConnection misuse #565

Closed

Description

@bgrainger

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.

Activity

  1. bgrainger commented on Sep 29, 2018

    @bgrainger
    MemberAuthor

    Implemented in 0.45.1.

  2. bgrainger commented on Oct 1, 2018

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions