我正在尝试连接到C#WPF应用程序中的远程服务器。我收到了错误:
'MySql.Data.MySqlClient.MySqlException'附加信息:无法连接到任何指定的MySQL主机。
这是我的数据库连接代码和查询:
private void CreateModule_Click(object sender, RoutedEventArgs e)
{
string connString = "Server=188.121.44.186:3306; Database=**; Uid=********; Pwd=********;";
MySqlConnection dbconn = new MySqlConnection(connString);
dbconn.Open();
isConnected = true;
try
{
string sql = "INSERT INTO modules ( `moduleCode`, `moduleTitle`, `moduleLevel`, `moduleActive`, `minStudents`, `maxStudents`) VALUES('" + textBoxCode.Text + "','" + textBoxTitle.Text + "' '" + levelBox.Text + "', '" + IsActive.ToString() + "' , '" + sliderMin.ToString() + "' , '" + sliderMax.ToString() + "') ;";
MySqlCommand sqlcmd = new MySqlCommand(sql, dbconn);
catch (Exception)
{
//MessageBox.Show("Database Connection Error");
}
if (isConnected == true)
{
var bc = new BrushConverter();
connStatus.Background = (Brush)bc.ConvertFrom("#69D693");
}
}
谢谢你的时间