本文整理汇总了C#中MySqlDbType类的典型用法代码示例。如果您正苦于以下问题:C# MySqlDbType类的具体用法?C# MySqlDbType怎么用?C# MySqlDbType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySqlDbType类属于命名空间,在下文中一共展示了MySqlDbType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddParameter
/// <summary>
/// Binds a parameter to the command with the given value and type.
/// </summary>
/// <param name="parameterName">
/// The parameter Name.
/// </param>
/// <param name="value">
/// The value.
/// </param>
/// <param name="type">
/// The type.
/// </param>
public void AddParameter(string parameterName, object value, MySqlDbType type)
{
var parameter = new MySqlParameter();
parameter.ParameterName = parameterName;
parameter.Value = value;
this.Command.Parameters.Add(parameter);
}
示例2: MySqlParameter
/// <summary>
/// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, the size, and the source column name.
/// </summary>
/// <param name="parameterName">The name of the parameter to map. </param>
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
/// <param name="size">The length of the parameter. </param>
/// <param name="sourceColumn">The name of the source column. </param>
public MySqlParameter(string parameterName, MySqlDbType dbType, int size, string sourceColumn) : this(parameterName, dbType)
{
Size = size;
Direction = ParameterDirection.Input;
SourceColumn = sourceColumn;
SourceVersion = DataRowVersion.Current;
}
示例3: MySqlGeometry
internal MySqlGeometry(MySqlDbType type, Double xValue, Double yValue, int srid)
{
this._type = type;
this._xValue = xValue;
this._yValue = yValue;
this._isNull = false;
this._srid = srid;
this._valBinary = new byte[GEOMETRY_LENGTH];
byte[] sridBinary = BitConverter.GetBytes(srid);
for (int i = 0; i < sridBinary.Length; i++)
_valBinary[i] = sridBinary[i];
long xVal = BitConverter.DoubleToInt64Bits(xValue);
long yVal = BitConverter.DoubleToInt64Bits(yValue);
_valBinary[4] = 1;
_valBinary[5] = 1;
for (int i = 0; i < 8; i++)
{
_valBinary[i + 9] = (byte)(xVal & 0xff);
xVal >>= 8;
}
for (int i = 0; i < 8; i++)
{
_valBinary[i + 17] = (byte)(yVal & 0xff);
yVal >>= 8;
}
}
示例4: CreateParameter
public static MySqlParameter CreateParameter(ParameterDirection direction, string paramName, MySqlDbType dbtype, int size, object value)
{
MySqlParameter param = new MySqlParameter(paramName, dbtype, size);
param.Value = value;
param.Direction = direction;
return param;
}
示例5: DbTypeToString
public string DbTypeToString(MySqlDbType type, int? length)
{
string ret;
if (TypesAsStrings.TryGetValue(type, out ret))
return ret + (length != null ? "({0})".SFormat((int)length) : "");
throw new NotImplementedException(Enum.GetName(typeof(MySqlDbType), type));
}
示例6: MySqlBinary
public MySqlBinary(MySqlDbType type, byte[] val)
{
this.type = type;
this.isNull = false;
this.mValue = val;
this.IsGuid = false;
}
示例7: MakeParam
///<summary>
///</summary>
///<param name="paramName"></param>
///<param name="dbType"></param>
///<param name="size"></param>
///<param name="direction"></param>
///<param name="value"></param>
///<returns></returns>
///<exception cref="ArgumentOutOfRangeException"></exception>
public static MySqlParameter MakeParam(string paramName, MySqlDbType dbType, int size, ParameterDirection direction, object value)
{
MySqlParameter sqlParameter = null;
try
{
paramName = paramName ?? string.Empty;
//modify reason:验证花时比较大
//if (!MathUtils.IsMachVarName(paramName))
//{
// throw new ArgumentOutOfRangeException("paramName", "参数名格式不正确");
//}
if (size > 0)
{
sqlParameter = new MySqlParameter(FormatParamName(paramName), dbType, size);
}
else
{
sqlParameter = new MySqlParameter(FormatParamName(paramName), dbType);
}
sqlParameter.Direction = direction;
if (direction != ParameterDirection.Output || value != null)
{
sqlParameter.Value = value;
}
}
catch (Exception ex)
{
TraceLog.WriteError("{0}", ex);
}
return sqlParameter;
}
示例8: DbTypeToString
public string DbTypeToString(MySqlDbType type, int? length)
{
string ret;
if (TypesAsStrings.TryGetValue(type, out ret))
return ret;
throw new NotImplementedException(Enum.GetName(typeof(MySqlDbType), type));
}
示例9: SetDSInfo
internal static void SetDSInfo(DataTable dsTable) {
string[] strArray = new string[] { "INT", "YEAR", "MEDIUMINT" };
MySqlDbType[] typeArray = new MySqlDbType[] { MySqlDbType.Int32, MySqlDbType.Year, MySqlDbType.Int24 };
for (int i = 0; i < strArray.Length; i++) {
DataRow row = dsTable.NewRow();
row["TypeName"] = strArray[i];
row["ProviderDbType"] = typeArray[i];
row["ColumnSize"] = 0;
row["CreateFormat"] = strArray[i];
row["CreateParameters"] = null;
row["DataType"] = "System.Int32";
row["IsAutoincrementable"] = typeArray[i] != MySqlDbType.Year;
row["IsBestMatch"] = true;
row["IsCaseSensitive"] = false;
row["IsFixedLength"] = true;
row["IsFixedPrecisionScale"] = true;
row["IsLong"] = false;
row["IsNullable"] = true;
row["IsSearchable"] = true;
row["IsSearchableWithLike"] = false;
row["IsUnsigned"] = false;
row["MaximumScale"] = 0;
row["MinimumScale"] = 0;
row["IsConcurrencyType"] = DBNull.Value;
row["IsLiteralsSupported"] = false;
row["LiteralPrefix"] = null;
row["LiteralSuffix"] = null;
row["NativeDataType"] = null;
dsTable.Rows.Add(row);
}
}
示例10: getParameter
private static MySqlParameter getParameter(string Name, MySqlDbType Type, object Value)
{
MySqlParameter param = new MySqlParameter();
param.ParameterName = Name;
param.MySqlDbType = Type;
param.Value = Value;
return param;
}
示例11: AddParameter
public MySqlParameter AddParameter(string ParameterName, MySqlDbType type, int size, object value, ParameterDirection direction)
{
MySqlParameter param = new MySqlParameter(ParameterName, type, size);
param.Direction = direction;
param.Value = value;
Command.Parameters.Add(param);
return param;
}
示例12: addSqlParam
public static void addSqlParam(string name, ParameterDirection direction, int size, MySqlDbType type)
{
MySqlParameter sqlParam = new MySqlParameter();
sqlParam.ParameterName = name;
sqlParam.Direction = direction;
sqlParam.Size = size;
sqlParam.MySqlDbType = type;
sqlParms.Add(sqlParam);
}
示例13: MySqlGeometry
internal MySqlGeometry(MySqlDbType type, bool isNull)
{
this._type = type;
isNull = true;
_xValue = 0;
_yValue = 0;
_srid = 0;
_valBinary = null;
this._isNull = isNull;
}
示例14: AddParameter
/// <summary>
/// 增加SQL命令参数
/// </summary>
/// <param name="paraName">参数名</param>
/// <param name="paraValue">参数值</param>
/// <param name="paraDbType">数据类型</param>
/// <param name="paraSize">参数长度</param>
/// <param name="paraDirection">参数类型(in, out, inout)</param>
/// <returns></returns>
public static MySqlParameter AddParameter(string paraName, object paraValue, MySqlDbType paraDbType, int paraSize, ParameterDirection paraDirection)
{
MySqlParameter par = new MySqlParameter();
par.ParameterName = paraName;
par.Value = paraValue;
par.Direction = paraDirection;
par.MySqlDbType = paraDbType;
if (paraSize > 0)
par.Size = paraSize;
return par;
}
示例15: MySqlDateTime
public MySqlDateTime(MySqlDateTime mdt) {
this.year = mdt.Year;
this.month = mdt.Month;
this.day = mdt.Day;
this.hour = mdt.Hour;
this.minute = mdt.Minute;
this.second = mdt.Second;
this.millisecond = 0;
this.type = MySqlDbType.DateTime;
this.isNull = false;
}