Exemplo n.º 1
0
        private void GenerateSQL()
        {
            string BuildSQL = "INSERT INTO " + form_MM.GetAuthDB() + ".account (username, sha_pass_hash, expansion, email) " + "\n" +
                              "VALUES (UPPER('" + textBox_username.Text + "'), (SHA1(CONCAT(UPPER('" + textBox_username.Text + "'), ':', UPPER('" + textBox_pass.Text + "')))), " + textBox_Expansion.Text + ", '" + textBox_email.Text + "'); " + "\n" +
                              "INSERT INTO " + form_MM.GetAuthDB() + ".account_access (id, gmlevel, RealmID) " + "\n" +
                              "VALUES ((SELECT id FROM " + form_MM.GetAuthDB() + ".account WHERE username = '******'), " + textBox_Account_Access_Level.Text + ", " + textBox_realmID.Text + "); \n";

            stringSqlShare = BuildSQL;
        }
Exemplo n.º 2
0
        public void ShowExistingAccounts()
        {
            GetMySqlConnection();

            //string query = $"SELECT id, username, email FROM { form_MM.GetAuthDB() }.account;";

            //MySqlCommand _command = new MySqlCommand(query, connection);

            //try
            //{
            //    connection.Open();

            //    MySqlDataAdapter sda = new MySqlDataAdapter();
            //    sda.SelectCommand = _command;
            //    DataTable dbdataset = new DataTable();
            //    sda.Fill(dbdataset);
            //    BindingSource bsource = new BindingSource();

            //    bsource.DataSource = dbdataset;
            //    dataGridView1.DataSource = bsource;
            //    sda.Update(dbdataset);

            //    _command.Connection.Close();
            //}
            //catch (MySqlException ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}


            string query = $"SELECT id, username, email FROM { form_MM.GetAuthDB() }.account;";

            try
            {
                using (MySqlCommand cmd = new MySqlCommand(query, connection))
                {
                    MySqlDataAdapter sda = new MySqlDataAdapter();
                    sda.SelectCommand = cmd;
                    DataTable dbdataset = new DataTable();
                    sda.Fill(dbdataset);
                    dataGridView1.DataSource       = dbdataset;
                    dataGridView1.Columns[0].Width = 50;  // Entry
                    dataGridView1.Columns[1].Width = 160; // Name
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error No. " + ex.Number + ": " + ex.Message, "SpawnCreator", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }