I'm trying to connect to my mysql database (I'm hosted by infinityfree.net), entering these credentials:
connection = new MySqlConnection("Server=sql306.epizy.com; Port=3306; Database=epiz_27674946_db1; Uid=epiz_27674946; Pwd=**********; "); But I get this exception:
Unable to connect to any of the specified mysql hosts I don't know why this happens, the credentials should be right...
Can you help me?
Full code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace sharetru { public partial class Form1 : Form { public Form1() { InitializeComponent(); } MySqlConnection connection; private void Form1_Load(object sender, EventArgs e) { try { connection = new MySqlConnection("Server=sql306.epizy.com; Port=3306; Database=epiz_27674946_db1; Uid=epiz_27674946; Pwd=*******; "); connection.Open(); if (connection.State == ConnectionState.Open) { label1.Text = "Connected"; label1.ForeColor = Color.Green; } else { label1.Text = "Not Connected"; label1.ForeColor = Color.Red; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
if (connection.State == ConnectionState.Open)is a pointless if statement - theelseis incredibly unlikely to be entered.