TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shahul mechery
NA
59
1.7k
ODBC - MySQL Connection error in c#
Oct 9 2013 2:24 AM
I tried to access MySql Database using ODBC in C#
But i got an error as:
ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on 'localhost' (10061)
Whats wrong here? What i have to recheck in my control panel settings?
Code is as follows:
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();
}
}
Reply
Answers (
1
)
how to clear web browser cache in c#.net windows application
MVC4 Reference and render jquery file