When I try to connect to the database, it displays an error. When I connect to the database from my computer, everything is fine, and when to the hosting database, the error is:
Caused an exception: "MySql.Data.MySqlClient.MySqlException" in MySql.Data.dll
More information: Authentication to host 'localhost' for user 'id835937_root' using method 'mysql_native_password' failed with message
Code:
string conStr = "SERVER=localhost;" + "DATABASE=!;" + "UID=!;" + "PASSWORD=!;"; using (MySqlConnection con = new MySqlConnection(conStr)) { try { string sql = "INSERT INTO `articles` (`article_title`, `article_text`) VALUES ('hi', 'hello');"; MySqlCommand cmd = new MySqlCommand(sql, con); con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Данные добавлены!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
MessageBox.Show(ex.Message);Your program starts on your computer and connects to the database, a cat. on hosting? If yes, then you need to specify the server address, and not lokalkhost. - Bulson