变量类型上 integer,在数据库的字段要选什么类型。(有15位数字)
在数据库存自动生成时间,格式为:2004-11-20  ,要怎么设。

解决方案 »

  1.   

    15位数字就要用bigint了
    自动生成时间,用getdate()
    如:
    ALTER TABLE [dbo].[Dv_Friend] WITH NOCHECK ADD 
    CONSTRAINT [DF_Dv_Friend_F_addtime] DEFAULT (getdate()) FOR [F_addtime],
    GO企业管理器中设计表的时候列的默认值改成getdate()就可以了
      

  2.   

    /// <summary>
            ///   将 DbType 类型  转换 为 系统类型。
            /// <bug>现在不能转换 DbType.Date DbType.Guid DbType.Time DbType.VarNumeric 类型</bug>
            /// </summary>
            /// <param name="dbType">要转换的 DbType 类型</param>
            /// <returns>Type Object</returns>
            public static Type Convert(DbType dbType)
            {
                Type retType;
                switch (dbType)
                {
                    case DbType.AnsiString :
                    case DbType.AnsiStringFixedLength:
                    case DbType.String:
                    case DbType.StringFixedLength:
                        retType = typeof(System.String);
                        break;
                    case DbType.Binary:
                        retType = typeof(System.Byte[]);
                            break;
                    case DbType.Boolean:
                        retType = typeof(System.Boolean);
                        break;
                    case DbType.Byte:
                        retType = typeof(System.Byte);
                        break;
                    case DbType.Currency:
                    case DbType.Decimal:
                        retType = typeof(System.Decimal);
                        break;
                        //case DbType.Date:
                    case DbType.DateTime:
                        retType = typeof(System.DateTime);
                        break;
                    case DbType.Double:
                        retType = typeof(System.Double);
                        break;
                        //case DbType.Guid:
                    case DbType.Int16:
                        retType = typeof(System.Int16);
                        break;
                    case DbType.Int32:
                        retType = typeof(System.Int32);
                        break;
                    case DbType.Int64:
                        retType = typeof(System.Int64);
                        break;
                    case DbType.Object:
                        retType = typeof(System.Object);
                        break;
                    case DbType.SByte:
                        retType = typeof(System.SByte);
                        break;
                    case DbType.Single:
                        retType = typeof(System.Single);
                        break;
                        //case DbType.Time:
                    case DbType.UInt16:
                        retType = typeof(System.UInt16);
                        break;
                    case DbType.UInt32:
                        retType = typeof(System.UInt32);
                        break;
                    case DbType.UInt64 :
                        retType = typeof(System.UInt64);
                        break;
                        //case DbType.VarNumeric              
                    default:
                        retType = null;
                        break;
                }
                if (retType == null)
                {
                    throw new InvalidOperationException("current  type converting is not support.");
                }
                return   retType;
            }
      

  3.   

    1数据库字段使用bigint程序中使用Int64
    2默认值设为getdate()
      

  4.   

    1数据库字段使用bigint程序中使用Int64
    2默认值设为getdate()
    agree!
      

  5.   

    nod
    不过getdate()后有时间(分,秒),要去掉
      

  6.   

    不过getdate()后有时间(分,秒),要去掉