0

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();

7
  • 1
    Did you tried to enter your username and password without ';' ? Commented Nov 24, 2021 at 18:50
  • @Sajed what do you mean? i dont use ";" Commented Nov 24, 2021 at 18:55
  • @Dmitry i will try it! :D Commented Nov 24, 2021 at 18:59
  • 2
    Just to be clear, you tried and verified all answers from the question @Dmitry linked to, in 5 minutes? Commented Nov 24, 2021 at 19:39
  • 1
    You have a bunch of other issues: You need using to dispose all the MySql objects. 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. Commented Nov 24, 2021 at 21:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.