コード例 #1
0
        public void AddProfileColumn( string Name, FbDbType columnType, int size)
        {
            // get column type...
            string type = columnType.ToString();
               // FbDbType.SmallInt
               // FbDbType.TimeStamp
              //  FbDbType.VarChar
              //  FbDbType.Integer

            if (type.ToLower()=="timestamp")
            { type = "TimeStamp"; }

            if ( size > 0 )
            {
                type += "(" + size.ToString() + ")";
            }
            if ( type.Contains("VarChar") && MsSqlDbAccess.DatabaseEncoding !=null)
            {
                type += " CHARACTER SET " + MsSqlDbAccess.DatabaseEncoding;

                      if (MsSqlDbAccess.DatabaseCollation !=null)
                  {
                      type += " COLLATE " +  MsSqlDbAccess.DatabaseCollation;
                  }
            }

            string sql = String.Format(@"ALTER TABLE {0} ADD {1}  {2};", MsSqlDbAccess.GetObjectName("P_profile"), Name, type);

            using ( FbCommand cmd = new FbCommand( sql ) )
            {
                cmd.CommandType = CommandType.Text;
                _dbAccess.ExecuteNonQuery(cmd );
            }
        }
コード例 #2
0
        /// <summary>
        /// The add profile column.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="columnType">
        /// The column type.
        /// </param>
        /// <param name="size">
        /// The size.
        /// </param>
        public static void AddProfileColumn( [NotNull] string name, FbDbType columnType, int size)
        {
            // get column type...
            string type = columnType.ToString();

            if (size > 0)
            {
                type += "(" + size + ")";
            }

            string sql = "ALTER TABLE {0} ADD {1} {2} ".FormatWith(
              MsSqlDbAccess.GetObjectName("UserProfile"), name, type);

            using (var cmd = MsSqlDbAccess.GetCommand(sql, true))
            {
                cmd.CommandType = CommandType.Text;
                MsSqlDbAccess.Current.ExecuteNonQuery(cmd);
            }
        }