Cry about...
MS-Windows Troubleshooting


The connection has been disabled


Symptom:

When using an OdbcDataAdapter to add a record to a MySQL database the follow exception is thrown:

{System.InvalidOperationException}
    System.InvalidOperationException: {"The connection has been disabled."}
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: Nothing
    InnerException: {"ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.51b-community-nt]Got a packet bigger than 'max_allowed_packet' bytes"}
    Message: "The connection has been disabled."
    Source: "System.Data"

Possible Causes

The message "The connection has been disabled" seems to be a generic error message.

The important thing is the "InnerException", since this shows what the underlying error was. This is the true error which needs to be addressed.

In this particular example, the InnerException was:

InnerException: {"ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.51b-community-nt]Got a packet bigger than 'max_allowed_packet' bytes"}

showing that the max_allowed_packet size for MySQL needed to be increased.


These notes have been tested within Microsoft Visual Studio .NET 2005 for .NET 2 running under Windows Vista Professional connecting to MySQL, and may apply to other versions as well.



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.