I have a web API hosted on Heroku. It serves data from a ClearDB via a Golang program. I have a C# .NET script that will need to insert data into that ClearDB. I had this idea working on my local machine, but as I moved everything over to heroku, the C# part stopped working.
I have been successful in connecting with MySQL Workbench 8.0 and with my Golang program itself. The GO program can successfully connect, query, and serve data.
I know there are many other questions like this, and most of them seem to be solved with the connection string. I have tried almost ALL of the different ways you can string up a connection string. This is what i last tried (credentials have been changed to random letters):
connectionData = @"Server = eu-cd-steel-west-01.cleardb.net; Port = 3306; Database = heroku_555555555; Uid = b7039sldk253; Pwd = e3502ldks;";
The error I am getting happens when I run this:
connection = new MySqlConnection(connectionData); connection.Open();
MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings) at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.NativeDriver.Open() 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.GetPooledConnection() at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at MySql.Data.MySqlClient.MySqlPool.GetConnection() at MySql.Data.MySqlClient.MySqlConnection.Open() at DatabaseTesting.DataBaser.connect() in C:\Users\surf.user\source\repos\DatabaseTesting\DatabaseTesting\DataBaser.cs:line 38
I understand there are SSL credentials and all sorts of stuff, but I am lead to believe that doesn't matter as I didn't have to configure anything special to connect on workbench. Is there anything extra I need to do to successfully open the ClearDB connection on C#?
I suspect you're running into this known bug in Oracle's MySQL Connector/NET: bug 97448. (I can't resolve the domain name you gave in the question, but if it resolves to more than one
A record then that will trigger the bug.)
The fix is to uninstall the
MySql.Data NuGet package and install
MySqlConnector instead: https://www.nuget.org/packages/MySqlConnector/
This supports the same API as MySql.Data, so it should be a drop-in replacement.
User contributions licensed under CC BY-SA 3.0