Mr.Wang from Next Door
Mr.Wang from Next Door

Reputation: 14820

Always failed to connect mySQL database in ASP.Net

Environment: Windows 2008 R2 & ASP.Net 4.0

Connector/Net 6.6.4 from here

NOTE: I selected the ".Net / Mono" platform and downloaded the architecture-independent version. Enable-32-bit-application-in-IIS is not an option for me.

I try to connect the mySQL database via the following connection string.

Server=192.168.1.200;Port=3306;Database=gm_log;Uid=cf2;Pwd=123456;Charset=utf8;AllowUserVariables=True;Allow Zero Datetime=false;PersistSecurityInfo=false;Pooling=true;ConnectionLifeTime=0;Max Pool Size=100;Min Pool Size=1;

And MySqlConnection.Open throw an OverflowException. Arithmetic operation resulted in an overflow

Here is the stack trace.

at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.HandleAuthChange(MySqlPacket packet)
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool..ctor(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPoolManager.GetPool(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlConnection.Open()

Anyone else encounter the same issue?

Upvotes: 3

Views: 2892

Answers (2)

matty_simms
matty_simms

Reputation: 144

I had to same problem. But I used Nuget to install the MySql.Data package. If you are using Nuget you can downgrade the version using the following command in the Library Package Manager Console.

Install-Package MySql.Data -Version x.x.x.x

Where x.x.x.x is the older version. In my case I went back as far as I could and used 5.1.7.0. You can check the nuget site to see what versions are available or you can use the console again with the following command.

PM> Get-Package -ListAvailable -AllVersions -Filter MySql.Data

Id                             Version              Description/Release Notes                                                                                                                      
--                             -------              -------------------------                                                                                                                      
Ming.MySql.Data                6.5.4.0              ADO.Net driver for MySQL                                                                                                                       
MySql.Data                     5.1.7.0              Connector/Net is a fully-managed ADO.NET driver for MySQL.                                                                                     
MySql.Data                     6.2.5                Connector/Net is a fully-managed ADO.NET driver for MySQL.                                                                                     
MySql.Data                     6.3.7                Connector/Net is a fully-managed ADO.NET driver for MySQL.                                                                                     
MySql.Data                     6.4.4                Connector/Net is a fully-managed ADO.NET driver for MySQL.                                                                                     
MySql.Data                     6.5.4                Connector/Net is a fully-managed ADO.NET driver for MySQL.                                                                                     
MySql.Data                     6.6.4                Connector/Net is a fully-managed ADO.NET driver for MySQL.                                                                                     
MySQL.Data.Entities            6.4.4.0              Connector/Net is a fully-managed ADO.NET driver for MySQL.  Entity Framework support package (Mysql.Data.Entities).                            
MySQL.Data.Entities            6.5.4.0              Connector/Net is a fully-managed ADO.NET driver for MySQL.  Entity Framework support package (Mysql.Data.Entities).       

Edit: After more experimentation I determined that I only had to go back to 6.4.4 rather than 5.1.7.0. There were other issues around going back that far.

Upvotes: 3

Termit
Termit

Reputation: 609

Downgraded to previous version from here:

http://dev.mysql.com/downloads/connector/net/6.5.html#downloads

It now works for me.

Upvotes: 5

Related Questions