大家好我正在创建一个Windows应用程序登录页面。它连接到远程MySQL数据库。
经过测试,我意识到我正在运行VPN。这是对数据库的访问仍然很好。
现在,当我在没有VPN的情况下运行它时,我收到此错误:
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.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at ConnectToDataBase.Form1.LoginWthPasswordHashFunction() in C:\Users\ee\Dropbox\ConnectToDataBase\ConnectToDataBase\Form1.cs:line 38
有人能在这里指出我的错误,我会非常感激。
这是我的连接字符串:
connectionString="Server=MYSQL5016.myWindowsHosting.com;Database=db_123regis;Uid=a123regis;Pwd=**********"
以下是程序尝试连接数据库的代码:
String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
conn.Open();
queryStr = "SELECT slowHashSalt FROM userregistration WHERE email=?email ";
cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
cmd.Parameters.AddWithValue("?email", textBoxUsername.Text);
reader = cmd.ExecuteReader();
答案 0 :(得分:0)
如果您的默认端口不同,请尝试使用此格式
服务器= myServerAddress;端口= 1234;数据库= MYDATABASE; UID =名为myUsername; PWD = MYPASSWORD;