• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SqlDbType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SqlDbType的典型用法代码示例。如果您正苦于以下问题:C# SqlDbType类的具体用法?C# SqlDbType怎么用?C# SqlDbType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlDbType类属于命名空间,在下文中一共展示了SqlDbType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddSqlParameter

        /// <summary>
        /// SQLのパラメータを追加します。サニタイジング(SQLインジェクション対策)をします
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="direction"></param>
        /// <param name="paramName"></param>
        /// <param name="type"></param>
        /// <param name="value">値がnullの場合はDBNull.Valueを挿入します</param>
        public static void AddSqlParameter(SqlCommand cmd, ParameterDirection direction, string paramName, SqlDbType type, Object value)
        {
            if (cmd == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(paramName) || string.IsNullOrWhiteSpace(paramName))
            {
                return;
            }

            if (value == null)
            {
                value = DBNull.Value;
            }

            SqlParameter param = cmd.CreateParameter();
            param.ParameterName = paramName;
            param.SqlDbType = type;
            param.Direction = direction;
            param.Value = value;

            cmd.Parameters.Add(param);
        }
开发者ID:hiroakit,项目名称:blog,代码行数:33,代码来源:HNKSqlCommandHelper.cs


示例2: CreateParameter

 /// <summary>
 /// 매개 변수를 사용하여 <c>SqlParameter</c>클래스의 새 인스턴스를 반환합니다.
 /// </summary>
 /// <param name="parameterName">매핑할 매개 변수의 이름</param>
 /// <param name="dbType"><c>SqlDbType</c>값 중 하나</param>
 /// <param name="size">매개 변수의 길이</param>
 /// <param name="direction"><c>ParameterDirection</c>값 중 하나</param>
 /// <returns><c>SqlParameter</c>클래스의 새 인스턴스</returns>
 public static SqlParameter CreateParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction)
 {
     SqlParameter ret = CreateParameter(parameterName, dbType);
     ret.Direction = direction;
     ret.Size = size;
     return ret;
 }
开发者ID:tomochandv,项目名称:Test,代码行数:15,代码来源:SqlParameterhelper.cs


示例3: AddParameter

 public void AddParameter(string paramName, SqlDbType paramType, object paramValue)
 {
     SqlParameter prm = new SqlParameter(paramName, paramType);
     prm.Direction = ParameterDirection.Input;
     prm.Value = paramValue;
     m_Cmd.Parameters.Add(prm);
 }
开发者ID:stevehjohn,项目名称:Hub,代码行数:7,代码来源:DB.cs


示例4: SqlDataType

 private SqlDataType(SqlDbType type, int? length, int? precision, int? scale)
 {
     _Type = type;
     _Length = length;
     _Precision = precision;
     _Scale = scale;
 }
开发者ID:harite,项目名称:SqlChop,代码行数:7,代码来源:SqlDataType.cs


示例5: SqlParam

 public SqlParam(string paramName, object paramValue, ParameterDirection paramDirection, SqlDbType type)
 {
     Name = paramName;
     Direction = paramDirection;
     Value = paramValue;
     Type = type;
 }
开发者ID:girmateshe,项目名称:OAuth,代码行数:7,代码来源:SqlParam.cs


示例6: StoredProcedureParameterAttribute

 public StoredProcedureParameterAttribute(SqlDbType dataType, StoredProcedureParameterOptions options, int size)
 {
     DataType = dataType;
     Options = options;
     Direction = ParameterDirection.Input;
     Size = size;
 }
开发者ID:ArthurYiL,项目名称:EntityFrameworkExtras,代码行数:7,代码来源:StoredProcedureParameterAttribute.cs


示例7: StoredProcParameter

 /// <summary>
 /// Create new Store proc parameter.
 /// </summary>
 /// <param name="paramName">Sql parameter name.</param>
 /// <param name="paramType"><see cref="SqlDbType"/> parameter type.</param>
 /// <param name="paramSize"><see cref="Int32"/> sql parameter size - use with string.</param>
 /// <param name="usedFor1">Identifies the purpose of the parameter.</param>
 internal StoredProcParameter(string paramName,
     SqlDbType paramType,
     int paramSize,
     SqlStatementType usedFor1)
     : this(paramName, paramType, paramSize, new[] {usedFor1})
 {
 }
开发者ID:KarolV,项目名称:Translator,代码行数:14,代码来源:StoredProcParameter.cs


示例8: SqlMetaData

		public SqlMetaData (string name, SqlDbType type, byte precision, byte scale)
		{
			this.name = name;
			this.precision = precision;
			this.scale = scale;
			this.sqlDbType = type;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:SqlMetaData.cs


示例9: ConvertToSystemDataType

        public static string ConvertToSystemDataType(SqlDbType sqlDbType)
        {
            switch (sqlDbType)
            {
                case SqlDbType.BigInt:
                    return "System.Int64";

                case SqlDbType.Bit:
                    return "System.Boolean";

                case SqlDbType.DateTime:
                case SqlDbType.SmallDateTime:
                    return "System.DateTime";

                case SqlDbType.Decimal:
                case SqlDbType.Float:
                case SqlDbType.Money:
                case SqlDbType.Real:
                case SqlDbType.SmallMoney:
                    return "System.Decimal";

                case SqlDbType.Int:
                    return "System.Int32";

                case SqlDbType.UniqueIdentifier:
                    return "System.Guid";

                case SqlDbType.SmallInt:
                    return "System.Int16";

                case SqlDbType.TinyInt:
                    return "System.Byte";
            }
            return "System.String";
        }
开发者ID:fmanoellima,项目名称:Report-Generator-Service,代码行数:35,代码来源:Misc.cs


示例10: genSqlParameter

        protected SqlParameter genSqlParameter(String paramName, SqlDbType type, int size, Object value)
        {
            if (value == null)
                value = DBNull.Value;

            SqlParameter param = null;

            if (type == SqlDbType.DateTime)
            {
                if (value == DBNull.Value)
                {
                    param = new SqlParameter(paramName, value);
                }
                else
                {
                    param = new SqlParameter(paramName, ((Nullable<DateTime>)value).Value);
                }
            }
            else
            {
                param = new SqlParameter(paramName, type, size);
                param.Value = value;
            }

            return param;
        }
开发者ID:zyh329,项目名称:fpv2,代码行数:26,代码来源:BaseDAO.cs


示例11: executaProc

        /// <summary>
        /// Método genérico que chama os métodos correspondentes ao Tipo do Banco para execução da Procedure.
        /// </summary>
        /// <param name="query"></param>
        /// <param name="tipoBanco"></param>
        /// <returns></returns>
        public bool executaProc(string nameProc, TipoBanco tipoBanco, object[] values, string[] parametros, SqlDbType[] sqlDBType)
        {
            bool bRet = false;
            try
            {
                switch (tipoBanco)
                {
                    case TipoBanco.SQLServer:
                        bRet = executaProcSQL(nameProc, values, parametros, sqlDBType);
                        break;
                    case TipoBanco.Oracle:
                        break;
                    case TipoBanco.OLDB:
                        break;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                bRet = false;
                throw ex;
            }
            finally
            {

            }
            return bRet;
        }
开发者ID:tonfranco,项目名称:GerecaoInserts,代码行数:35,代码来源:clDataAccess.cs


示例12: DbParam

 public DbParam(String paramName, Object paramValue, SqlDbType paramType)
 {
     ParamName = paramName;
     ParamValue = paramValue;
     ParamType = paramType;
     ParamDirection = ParameterDirection.Input;
 }
开发者ID:rumbabu,项目名称:Yuvaas,代码行数:7,代码来源:DbParam.cs


示例13: MetaType

        public MetaType(byte precision, byte scale, int fixedLength, bool isFixed, bool isLong, bool isPlp, byte tdsType, byte nullableTdsType, string typeName, Type classType, Type sqlType, SqlDbType sqldbType, DbType dbType, byte propBytes) {
            this.Precision    = precision;
            this.Scale        = scale;
            this.FixedLength  = fixedLength;
            this.IsFixed      = isFixed;
            this.IsLong       = isLong;
            this.IsPlp        = isPlp;
            // can we get rid of this (?just have a mapping?)
            this.TDSType      = tdsType;
            this.NullableType = nullableTdsType;
            this.TypeName     = typeName;
            this.SqlDbType    = sqldbType;
            this.DbType       = dbType;

            this.ClassType    = classType;
            this.SqlType      = sqlType;
            this.PropBytes    = propBytes;

            IsAnsiType  = _IsAnsiType(sqldbType);
            IsBinType   = _IsBinType(sqldbType);
            IsCharType  = _IsCharType(sqldbType);
            IsNCharType = _IsNCharType(sqldbType);
            IsSizeInCharacters = _IsSizeInCharacters(sqldbType);
            IsNewKatmaiType = _IsNewKatmaiType(sqldbType);
            IsVarTime = _IsVarTime(sqldbType);

            Is70Supported = _Is70Supported(SqlDbType);
            Is80Supported = _Is80Supported(SqlDbType);
            Is90Supported = _Is90Supported(SqlDbType);
            Is100Supported = _Is100Supported(SqlDbType);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:31,代码来源:SqlEnums.cs


示例14: AddSqlPrameter

 //thoai Add sql parameter
 protected static SqlParameter AddSqlPrameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, object value)
 {
     SqlParameter parameter = new SqlParameter(parameterName, dbType, size);
     parameter.Direction = direction;
     parameter.Value = value;
     return parameter;
 }
开发者ID:damthoai,项目名称:tinh-viet-co,代码行数:8,代码来源:BaseDAO.cs


示例15: CreateParameter

 public static DbParameter CreateParameter(SqlDbType dbType)
 {
     return new SqlParameter
     {
         SqlDbType = dbType
     };
 }
开发者ID:mysticode,项目名称:Mystic,代码行数:7,代码来源:SqlDbFactory.cs


示例16: AddParameter

        /// <summary>
        /// Sets up a parameter for the query
        /// </summary>
        /// <param name="id">The ID of the parameter</param>
        /// <param name="type">The Sql type of the parameter</param>
        /// <param name="Value">The value of the parameter</param>
        public static void AddParameter(this List<SqlParameter> collection, string parameterName, SqlDbType type, Object Value)
        {
            SqlParameter parameter = new SqlParameter();
            parameter.ParameterName = parameterName;
            parameter.SqlDbType = type;

            if (Value == null)
            {
                parameter.Value = Convert.DBNull;
            }
            else if (Value.ToString() == "" && type != SqlDbType.VarChar)
            {
                // must convert the empty string to a DBNull
                parameter.Value = Convert.DBNull;
            }
            else if (Value.ToString() == "" && (type == SqlDbType.Float || type == SqlDbType.Int || type == SqlDbType.Money))
            {
                parameter.Value = 0;
            }
            else
            {
                // set the value of the parameter
                parameter.Value = Value;
            }

            collection.Add(parameter);
        }
开发者ID:pimbrouwers,项目名称:cinch,代码行数:33,代码来源:SqlParameterCollectionExtensions.cs


示例17: Create

 public string Create(string name, SqlDbType sqlDbType, long? length = null)
 {
     var lStr = length.HasValue
                    ? string.Format("({0})", length.Value)
                    : string.Empty;
     return string.Format("\"{0}\" {1}{2}", name.Trim(), sqlDbType.ToString().ToLower(), lStr);
 }
开发者ID:riberk,项目名称:CommonCC,代码行数:7,代码来源:SqlNativeTypeStringCreator.cs


示例18: SqlFieldAttribute

 public SqlFieldAttribute(string fieldName, int fieldLength, SqlDbType sqlDbType, bool needsSpellCheck)
 {
     this.m_FieldName = fieldName;
     this.m_FieldLength = fieldLength;
     this.m_SqlDbType = sqlDbType;
     this.m_NeedsSpellCheck = needsSpellCheck;
 }
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:7,代码来源:SqlFieldAttribute.cs


示例19: SmiExtendedMetaData

 internal SmiExtendedMetaData(SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, Type userDefinedType, string udtAssemblyQualifiedName, bool isMultiValued, IList<SmiExtendedMetaData> fieldMetaData, SmiMetaDataPropertyCollection extendedProperties, string name, string typeSpecificNamePart1, string typeSpecificNamePart2, string typeSpecificNamePart3) : base(dbType, maxLength, precision, scale, localeId, compareOptions, userDefinedType, udtAssemblyQualifiedName, isMultiValued, fieldMetaData, extendedProperties)
 {
     this._name = name;
     this._typeSpecificNamePart1 = typeSpecificNamePart1;
     this._typeSpecificNamePart2 = typeSpecificNamePart2;
     this._typeSpecificNamePart3 = typeSpecificNamePart3;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:SmiExtendedMetaData.cs


示例20: SqlField

 public SqlField(int tableIndex, string fieldName, SqlDbType dataType, bool visible)
 {
     this.tabIndex = tableIndex;
      this.fldName = fieldName;
      this.dbType = dataType;
      this.visible = visible;
 }
开发者ID:ffcouto,项目名称:FreeSQL,代码行数:7,代码来源:SqlField.cs



注:本文中的SqlDbType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SqlExecutor类代码示例发布时间:2022-05-24
下一篇:
C# SqlDatabase类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap