示例#1
0
        /// <summary>
        /// 创建表格
        /// </summary>
        /// <returns>是否成功</returns>
        public Boolean createTable(MySqlSlot[] slots)
        {
            lock (this)
            {
                try
                {
                    StringBuilder sb = new StringBuilder();

                    for (int i = 0; i < slots.Length; i++)
                    {
                        MySqlSlot slot = slots[i];
                        sb.Append(slot.flag);
                        if (i < slots.Length - 1)
                        {
                            sb.Append(", ");
                        }
                    }

                    this.Command = new MySqlCommand("CREATE TABLE " + this.Schema + "." + this.Table + "(" + sb.ToString() + ");", Connection);
                    this.Connection.Open();
                    this.Reader = this.Command.ExecuteReader();

                    while (this.Reader.Read())
                    {
                        this.closeReader();
                        this.Connection.Close();
                        return(true);
                    }
                }
                catch (MySqlException ex)
                {
                    this.closeReader();
                    this.Connection.Close();
                    ConsolePlusLib.Console.Out.println(Level.Severe, ex.ToString());
                }
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 创建表格
        /// </summary>
        /// <returns>是否成功</returns>
        public Boolean createTable(MySqlSlot[] slots)
        {
            lock (this)
            {
                try
                {
                    StringBuilder sb = new StringBuilder();

                    for (int i = 0; i < slots.Length; i++)
                    {
                        MySqlSlot slot = slots[i];
                        sb.Append(slot.flag);
                        if (i < slots.Length - 1)
                        {
                            sb.Append(", ");
                        }
                    }

                    this.Command = new MySqlCommand("CREATE TABLE " + this.Schema + "." + this.Table + "(" + sb.ToString() + ");", Connection);
                    this.Connection.Open();
                    this.Reader = this.Command.ExecuteReader();

                    while (this.Reader.Read())
                    {
                        this.closeReader();
                        this.Connection.Close();
                        return true;
                    }
                }
                catch (MySqlException ex)
                {
                    this.closeReader();
                    this.Connection.Close();
                    ConsolePlusLib.Console.Out.println(Level.Severe, ex.ToString());
                }
                return false;
            }
        }