Error message: "Unable to connect to any specified MySQL hosts" when i click on btn_Test. Im definitely entering a valid serverName and DatabaseName.
- public partial class MainForm : Form
- {
- public static string serverName;
- public static string database;
- public MainForm()
- {
- InitializeComponent();
- }
- MySqlConnection connection = new MySqlConnection("server=" + serverName + "; Database=" + database + "; username=username; password=password");
- public void btnTest_Click(object sender, EventArgs e)
- {
- serverName = txtServer.Text;
- database = txtDatabase.Text;
- try
- {
- connection.Open();
- MessageBox.Show("Connected!");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Poe FernandoPosted Jun 6, 2019, 11:09 PM