MYSQL Connector.NET link - connection string fails

Discussion in 'Databases' started by rdgarber, Feb 10, 2011.

  1. I am using MySQL Connector/Net 6.2.2, along with a C# WebService created in VS2008. This uses a DLL: MySql.Data.dll.
    1) I deploy my WebService on Winhost, copy in MySql.Data.dll, and it works fine until it gets to a MySQL command to open a connection, and then it always fails. (Error listed below).
    2) Running locally (not on the web) on my Windows 7 system, it runs perfectly using the same connection string.
    3) Similar code on Winhost using .ASPX also works perfectly using the same connection string:

    "server=my01.Winhost.com;user=dbuser;port=3306;password=mypassword;";

    Error Message:
    Error 500 - Internal Server Error-{"Message":"Unable to connect to any of the specified MySQL hosts.","StackTrace":" at MySql.Data.MySqlClient.NativeDriver.Open()\r\n at MySql.Data.MySqlClient.Driver.Open()\r\n at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)\r\n at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()\r\n at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()\r\n at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()\r\n at MySql.Data.MySqlClient.MySqlPool.GetConnection()\r\n at MySql.Data.MySqlClient.MySqlConnection.Open()\r\n at MySql.Data.MySqlClient.MySqlHelper.ExecuteDataset(String connectionString, String commandText, MySqlParameter[] commandParameters)\r\n at MySql.Data.MySqlClient.MySqlHelper.ExecuteDataset(String connectionString, String commandText)\r\n

    Code:

    [WebMethod]
    [ScriptMethod] //(ResponseFormat = ResponseFormat.Json)]
    public string SQLTest()
    {
    DBConnStr = "server=my01.Winhost.com;user=dbuser;port=3306;password=mypassword;";
    MySqlConnection conn = new MySqlConnection(DBConnStr);
    conn.Open();
    return "Success";
    }
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    It's hard to troubleshoot a full blown web application because there are so many pieces to it. I suggest you setup a simple subfolder and upload a simple script first in that subfolder. You may need to set that subfolder as an application folder. Create a simple application to connect to your database and troubleshoot it that way.

    The sample code you provided does not reveal much. For one thing it still doesn't tell us what MySQL Connector it is referencing if it is even referencing it at all.
     
  3. Last edited by a moderator: Oct 14, 2015

Share This Page