I am using C# and I am trying to connect to the MySQL database hosted by 00webhost.
I am getting error on the line connection.Open()
:
there is no mysql host with this parameters.
I have checked and everything seems to be fine.
string MyConString = "SERVER=mysql7.000webhost.com;" +
"DATABASE=a455555_test;" +
"UID=a455555_me;" +
"PASSWORD=something;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "INSERT Test SET lat=" +
OSGconv.deciLat + ",long=" + OSGconv.deciLon;
connection.Open();
Reader = command.ExecuteReader();
connection.Close();
What is wrong with this connection string?
This question is related to
c#
mysql
database-connection
Here is an example:
MySqlConnection con = new MySqlConnection(
"Server=ServerName;Database=DataBaseName;UID=username;Password=password");
MySqlCommand cmd = new MySqlCommand(
" INSERT Into Test (lat, long) VALUES ('"+OSGconv.deciLat+"','"+
OSGconv.deciLon+"')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
string MyConString = "Data Source='mysql7.000webhost.com';" +
"Port=3306;" +
"Database='a455555_test';" +
"UID='a455555_me';" +
"PWD='something';";
Source: Stackoverflow.com