每当我尝试这个代码时,它都会出现错误"无法连接到任何指定的mysql主机"我已经在我的localhost上测试了这个并且它成功但是当我在托管服务提供商上尝试这个代码时它就不会工作了!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace testingform
{
public partial class Form1 : Form
{
// Connection Variables;
MySqlConnection connection;
string connString;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
connString = @"SERVER= testwebsite.com;PORT=3306;DATABASE=mydatabase;UID=myuser;PASSWORD=mypassword;";
try
{
connection = new MySqlConnection();
connection.ConnectionString = connString;
connection.Open();
MessageBox.Show("Connection Success");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}