Example #1
0
        public override bool Table_Add(string table, M_SQL_Field field)
        {
            string sql      = "CREATE TABLE " + table + " ({0})";
            string fieldstr = field.fieldName + " ";

            switch (field.fieldType.ToLower())
            {
            case "int":
            case "money":
            case "ntext":
            case "bit":
            case "datetime":
                fieldstr += field.fieldType;
                break;

            default:
                fieldstr += field.fieldType + "(" + field.fieldLen + ") ";
                break;
            }
            if (!string.IsNullOrEmpty(field.defval))
            {
                fieldstr += " DEFAULT ('" + field.defval + "')";
            }
            return(SqlHelper.ExecuteSql(string.Format(sql, fieldstr)));
        }
Example #2
0
 public override bool Field_Add(string table, M_SQL_Field field)
 {
     DBHelper.Table_AddField(new M_SQL_Connection()
     {
         constr = ConnectionString, tbname = table
     }, field);
     return(true);
 }
Example #3
0
        public override bool Field_Add(string tbname, M_SQL_Field field)
        {
            string sql = "ALTER TABLE " + tbname + " ADD (" + field.fieldName + " " + field.fieldType + " (" + field.fieldLen + ") " + field.defval + ")";

            ExecuteNonQuery(new SqlModel()
            {
                sql = sql
            });
            return(true);
        }
Example #4
0
        public override bool Table_Add(string table, M_SQL_Field field)
        {
            string sql = "CREATE TABLE " + table + " (" + field.fieldName + " " + field.fieldType + " (" + field.fieldLen + ") " + field.defval + ")";

            ExecuteNonQuery(new SqlModel()
            {
                sql = sql
            });
            return(true);
        }
Example #5
0
        public override bool Field_Add(string table, M_SQL_Field field)
        {
            string sql = "ALTER TABLE " + table + " ADD COLUMN " + field.fieldName + " " + field.fieldType + "(" + field.fieldLen + ") DEFAULT NULL";

            ExecuteNonQuery(new SqlModel()
            {
                sql = sql
            });
            return(true);
        }
Example #6
0
        public override bool Table_Add(string table, M_SQL_Field field)
        {
            //CREATE TABLE `zoomlacms`.`test` (`ID` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(`ID`));
            string sql = "CREATE TABLE " + table + "(`" + field.fieldName + "` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(`" + field.fieldName + "`))";

            ExecuteNonQuery(new SqlModel()
            {
                sql = sql
            });
            return(true);
        }
Example #7
0
        public override bool Field_Add(string table, M_SQL_Field field)
        {
            //ALTER TABLE `zoomlacms`.`zl_c_article`  ADD COLUMN `test` TEXT NULL DEFAULT '12' AFTER `K_pages`;
            string sql = "ALTER TABLE `" + table + "` ADD COLUMN `" + field.fieldName + "` " + field.fieldType;

            if (field.fieldLen > 0)
            {
                sql += " (" + field.fieldLen + ") ";
            }
            sql += " DEFAULT NULL";
            ExecuteNonQuery(new SqlModel()
            {
                sql = sql
            });
            return(true);
        }
Example #8
0
        public override bool Table_Add(string table, M_SQL_Field field)
        {
            string sql      = "CREATE TABLE " + table + " ({0})";
            string fieldstr = field.fieldName + " ";

            switch (field.fieldType.ToLower())
            {
            case "int":
            case "money":
            case "ntext":
            case "bit":
            case "datetime":
                fieldstr += field.fieldType;
                break;

            default:
                fieldstr += field.fieldType + "(" + field.fieldLen + ") ";
                break;
            }
            //主键与默认值不同时存在
            //CREATE TABLE dbo." + model.TableName + " ([ID] [int] IDENTITY (1, 1) PRIMARY Key NOT NULL)
            if (field.ispk)
            {
                fieldstr += " IDENTITY (1, 1) PRIMARY Key NOT NULL";
            }
            else if (!string.IsNullOrEmpty(field.defval))
            {
                fieldstr += " DEFAULT ('" + field.defval + "')";
            }

            ExecuteNonQuery(new SqlModel()
            {
                sql = string.Format(sql, fieldstr)
            });
            return(true);
        }
 public override bool Field_Add(string table, M_SQL_Field field)
 {
     throw new NotImplementedException();
 }
Example #10
0
 public abstract bool Field_Add(string table, M_SQL_Field field);