ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on 'localhost' (10061)
private void Form2_Load(object sender, EventArgs e)
{
gridfill();
}
string MyConnectionString = @"server=localhost;userid=admin;password=admin;database=blood";
private void gridfill()
{
MySqlConnection con = null;
try
{
con = new MySqlConnection(MyConnectionString);
con.Open();
MySqlCommand cmd = con.CreateCommand();
//cmd.CommandText = "SELECT * FROM blood";
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = new MySqlCommand("SELECT * FROM blood", con);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
catch (MySqlException err)
{
MessageBox.Show("Error: " + err.ToString());
}
finally
{
con.Close();
}
}