我收到提示:連接帶MySQL.NET連接器
當我與MySQL .NET接口連接Could not establish a connection to database
。我完全確信用戶名是正確的,密碼是正確的,數據庫是正確的,服務器是正確的。下面的代碼:
mysqlCon.ConnectionString = "Server=(servername);Username=(username);Pwd=(rightpassword);
Database=(rightdatabase)";
try
{
mysqlCon.Open();
}
catch (Exception ex)
{
MessageBox.Show("Could not establish a connection to database!");
}
它migh TBE有用的打印ex.Message不是忽略它。如果您沒有使用捕獲的異常,請不要指定名稱(例如,使用_catch(Exception)_ – NKCSS 2011-04-09 14:33:40