Beispiel #1
0
        /// <summary>
        /// 增加字段进入数据库
        /// </summary>
        /// <param name="model">连结模型</param>
        /// <param name="field">字段模型</param>
        public static void Table_AddField(M_SQL_Connection model, M_SQL_Field field)
        {
            string sql = "ALTER TABLE [" + model.tbname + "] ADD [" + field.fieldName + "] ";

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

            default:
                sql += field.fieldType + "(" + field.fieldLen + ") ";
                break;
            }
            if (!string.IsNullOrEmpty(field.defval))
            {
                sql += " DEFAULT ('" + field.defval + "')";
            }
            if (string.IsNullOrEmpty(model.constr))
            {
                model.constr = DBCenter.DB.ConnectionString;
            }
            DBHelper.ExecuteSQL(model.constr, sql);
        }
Beispiel #2
0
 public static bool Table_IsExist(M_SQL_Connection model)
 {
     if (string.IsNullOrEmpty(model.tbname))
     {
         return(true);
     }
     try
     {
         string sql = "SELECT * FROM dbo.SysObjects WHERE ID = object_id(N'[" + model.tbname + "]') AND OBJECTPROPERTY(ID, 'IsTable') = 1";
         return(ExecuteTable(sql).Rows.Count > 0);
     }
     catch { return(false); }
 }
Beispiel #3
0
 public static void Table_Add(M_SQL_Connection model)
 {
 }