我正在尝试在我的测试WPF应用程序和MySql(phpmyadmin)数据库之间建立连接。 现在,我尝试了其他主题中有类似问题的所有建议,都没有效果。
我的用户拥有所有权限(http://prntscr.com/ehhrdv)和一个虚拟表。
我的连接代码如下所示:
string conectionString = "Server = r310.reseller.si; Database = ******; Uid = ******; Pwd = ******";
myConnection = new MySqlConnection(conectionString);
try { myConnection.Open(); } catch(MySqlException ex)
{
MessageBox.Show(ex.ToString());
}
我得到的错误:
MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.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()
at WpfApplication2.MainWindow.pressMe_Click(Object sender, RoutedEventArgs e) in C:\Users\Tomi\Documents\Visual Studio 2015\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 51
我不确定我的用户是否没有远程连接或其他东西的权限。
我正在从我的工作经销商网站管理数据库。
答案 0 :(得分:0)
尝试添加:
Driver = {SQL Server Native Client 11.0};
在连接字符串的开头,即:
string conectionString =" Driver = {SQL Server Native Client 11.0}; Server = r310.reseller.si; Database = ******; Uid = ******; Pwd = ** ****&#34 ;;