I am trying do to a program that sends you a verification code to register, but everytime i try it there comes this error:
MySql.Data.MySqlClient.MySqlException: "Authentication to host 'server' for user 'user' using method 'mysql_native_password' failed with message: Access denied for user 'user'@'p4fe986ad.dip0.t-ipconnect.de' (using password: YES)"
I searched for answers but i did not find some. so i thought i could ask a question too. Ah and yeah here is the code :D
Register r = new Register();
confirmed_pass = r.confirmpw.Text;
if (randomcode == code.Text.ToString())
{
string verbindungsdaten1 = "SERVER=server;" +
"DATABASE=db;" +
"UID=user;" +
"PASSWORD=password;";
MySqlConnection verbindung1 = new MySqlConnection(verbindungsdaten1);
string command = "INSERT INTO Accounts VALUES ('" + text + "', '" + utils.hashPassword(confirmed_pass) + "', false);";
MySqlCommand com = new MySqlCommand(command, verbindung1);
verbindung1.Open();
com.ExecuteNonQuery();
verbindung1.Close();
MessageBox.Show("Sucessfully registered Account!", "Sucess");
MainWindow login = new MainWindow();
login.Show();
this.Close();
}
The error comes here:
verbindung1.Open();
usingto dispose all theMySqlobjects. You should parameterize your SQL, otherwise you are open to SQL injection and syntax errors. Specify column names to insert into. Don't hardcode connection strings. There is a lack of error handling.