MySqlConnection open()永远不会返回

时间:2014-05-14 08:59:24

标签: c# mysql

我试图连接到远程MySql数据库以提取一些数据。我安装了MySqlConnector,但我的代码似乎不起作用。它永远不会从try块中消失(它永远不会打印Connection OK)。它能是什么?

string server = "serverIpAddress";
string database = "dbName";
string uid = "userName";
string password = "****";

string connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

MySqlConnection myConnection = new MySqlConnection(connectionString);

try
{
    Console.WriteLine("Trying to open"); 
    myConnection.Open();
    Console.WriteLine("Connection OK");
}
catch (Exception e)
{
    Console.WriteLine(e.InnerException);
}

Console.ReadKey();

0 个答案:

没有答案