Example #1
0
        private void buttonRegister_Click(object sender, EventArgs e)
        {
            if (Password == RepeatedPassword)
            {
                Dictionary <string, object> par = new Dictionary <string, object>
                {
                    { "@username", UserName },
                    { "@password", Password }
                };

                string Query = $"CREATE USER { UserName }@localhost IDENTIFIED BY '{ Password }';" +
                               $"GRANT SELECT ON ekstraklasa.* TO { UserName }@localhost;";

                _connection = DBconnection.Init("root", "");
                bool result = _connection.CreateUser(Query);
                if (result)
                {
                    MessageBox.Show($"Successfully created a new user { UserName }");
                    this.Close();
                    return;
                }
                else
                {
                    MessageBox.Show("Could not created a new user");
                }
            }
            else
            {
                MessageBox.Show("Passwords must match");
            }
        }