本文整理汇总了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);
}
示例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;
}
示例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);
}
示例4: SqlDataType
private SqlDataType(SqlDbType type, int? length, int? precision, int? scale)
{
_Type = type;
_Length = length;
_Precision = precision;
_Scale = scale;
}
示例5: SqlParam
public SqlParam(string paramName, object paramValue, ParameterDirection paramDirection, SqlDbType type)
{
Name = paramName;
Direction = paramDirection;
Value = paramValue;
Type = type;
}
示例6: StoredProcedureParameterAttribute
public StoredProcedureParameterAttribute(SqlDbType dataType, StoredProcedureParameterOptions options, int size)
{
DataType = dataType;
Options = options;
Direction = ParameterDirection.Input;
Size = size;
}
示例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})
{
}
示例8: SqlMetaData
public SqlMetaData (string name, SqlDbType type, byte precision, byte scale)
{
this.name = name;
this.precision = precision;
this.scale = scale;
this.sqlDbType = type;
}
示例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";
}
示例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;
}
示例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;
}
示例12: DbParam
public DbParam(String paramName, Object paramValue, SqlDbType paramType)
{
ParamName = paramName;
ParamValue = paramValue;
ParamType = paramType;
ParamDirection = ParameterDirection.Input;
}
示例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);
}
示例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;
}
示例15: CreateParameter
public static DbParameter CreateParameter(SqlDbType dbType)
{
return new SqlParameter
{
SqlDbType = dbType
};
}