예제 #1
0
        private void btCreateTable_Click(object sender, EventArgs e)
        {
            MySQLConnector con       = MySQLConnector.GetInstance();
            bool           connected = con.Open(mc.Config.DatabaseHost, mc.Config.Database, mc.Config.DatabaseUser, mc.Config.DatabasePassword);

            if (con.State == ConnectionState.Open)
            {
                try
                {
                    QueryResult result = con.TableExists(mc.Config.TableAdmin);
                    if (!result.HasError && !result.HasResult)
                    {
                        result = con.ExecuteSQL(String.Format(
                                                    " CREATE TABLE `{0}` ( " +
                                                    " `id` int(11) NOT NULL AUTO_INCREMENT, " +
                                                    " `name` varchar(100) DEFAULT NULL, " +
                                                    " `is_online` int(11) DEFAULT NULL, " +
                                                    " `seconds_online` int(11) DEFAULT NULL, " +
                                                    " `players_max` int(11) DEFAULT NULL, " +
                                                    " `players_online` int(11) DEFAULT NULL, " +
                                                    " `date_last_online` datetime DEFAULT NULL, " +
                                                    " `ip` varchar(100) DEFAULT NULL, " +
                                                    " `port` int(11) DEFAULT NULL, " +
                                                    " `guid` varchar(100) DEFAULT NULL, " +
                                                    " `country` varchar(150) DEFAULT NULL, " +
                                                    " `version` varchar(100) DEFAULT NULL, " +
                                                    " PRIMARY KEY (`id`) " +
                                                    " ) ENGINE=InnoDB AUTO_INCREMENT=435 DEFAULT CHARSET=latin1;"
                                                    ,
                                                    mc.Config.TableServer
                                                    ));
                        if (result.HasError)
                        {
                            MessageBox.Show(result.Exception.Message);
                        }
                        else
                        {
                            if (result.HasResult)
                            {
                                MessageBox.Show("Tables successfully created");
                            }
                        }
                    }
                    else
                    {
                        if (result.HasError)
                        {
                            MessageBox.Show(result.Exception.Message);
                        }
                        if (result.HasResult)
                        {
                            MessageBox.Show("Tables are allready created!");
                        }
                    }

                    //int result = con.Insert("web_admins", new String[] { "login", "password", "minecraft_name", "group_id" }, new Object[] { "Zic", "hldx", "Zicore", 0 });
                }
                catch
                {
                }

                Object[][] data = con.SelectDataSet("SELECT * FROM web_admins");
            }
        }