2

I have read through quite a few other sources and I am really confused. I am trying to connect to a MySQL server on my website. I am using a remote connection to access the MySQL server. I have whitelisted my IP address on the hosting server. In fact, I can open up the Server Explorer in Visual Studio 2012 and it will connect to the MySQL server just fine. It will run queries and display the results from the database.

I am utterly confused as to why it won't connect when I try to establish the connection in my code. After the server explorer makes the connection, it also gives you the connection string that it used to make the connection. I am using that string and it will not work. Please help me understand why the server explorer can find the MySQL database, yet my code will not connect to it.

I am working in C#.

Here is my connection string from Visual Studio (the server explorer saved the password):

server=66.147.244.102;User Id=correct username;Persist Security Info=True;database=correct database name
4

1 回答 1

1

这是我来自 Visual Studio 的连接字符串(服务器资源管理器保存了密码):

server=66.147.244.102;
User Id=correct username;
Persist Security Info=True;
database=correct database name

这看起来像一个 Microsoft SQL Server 连接字符串,您将使用SqlConnection. SqlConnection只知道如何连接到 Microsoft SQL Server 数据库……你需要用来MySqlConnection连接到你的 MySQL 数据库。

于 2013-11-08T06:45:54.110 回答