You are here:

C#/.net connection with cPanel Mysql


Dear Sir,
Previously I asked a ques : How to Uploading the Data from Window Application to cPanel MySQL Server?

You told me:
//Insert statement
public void Insert()
  string query = "INSERT INTO tableinfo (name, age) VALUES('John Smith', '33')";

  //open connection
  if (this.OpenConnection() == true)
      //create command and assign the query and connection from the constructor
      MySqlCommand cmd = new MySqlCommand(query, connection);
      //Execute command

      //close connection

By this code sometime I am able to insert and sometime it throws an error: "Unable to connect to any of the specified MySQL hosts."

Unable to understand the reason why & when it is acting differently.

Probably you are using a free host with a low quality connection. That's why you just fall on timeout. Try increasing connection.ConnectionTimeout and cmd.CommandTimeout to 60000. If it continues to fail, means it's time to pass to a paid host.

Hope that helps,



All Answers

Answers by Expert:

Ask Experts


Murat Mehmet


I can help with questions about desktop and web programming in C#, including SOAP, XML, database managing, custom controls, security etc.


I have been developing web and especially desktop applications in C# and VB.Net for almost 5 years. My programming life has begun with VB6 long time ago, so its about 8 years that I am in this business.

Was in R & D for 2 years in a popular Turkish technology website:

2011 Computer Engineering graduation in University of Trakia in Turkey.

©2017 All rights reserved.