我在尝试打开MySQL连接时遇到以下错误;错误:无法连接到任何指定的MySQL主机
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
at MySql.Data.MySqlClient.NativeDriver.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()
* 编辑:* 的ConnectionString:
public string strProvider = "Server=00.00.00.00;Database=someDatabase;Uid=someUser;Pwd=somePassword";
代码我使用:
string getCompany = "Select * From tbl_company";
MySqlConnection objMyCon = new MySqlConnection(strProvider);
objMyCon.Open();
MySqlCommand cmd = new MySqlCommand(getCompany, objMyCon);
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dt);
objMyCon.Close();
可以采取什么问题吗?
粘贴一些代码为你自己! – 2011-04-26 06:21:14
您是否可以使用客户端连接到您在代码中指定的连接参数的命令行连接到mysql? – Wes 2011-04-26 06:23:15
你能通过MySQL查询浏览器连接吗?什么是你的连接字符串 – V4Vendetta 2011-04-26 06:24:01