我在嘗試打開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