当前位置: 首页>>代码示例>>C#>>正文


C# SqlDbType类代码示例

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


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


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