public iDB2Parameter CreateParameter(string sName, iDB2DbType parameterType, int parameterSize, ParameterDirection paramDirection, string parameterValue) { var myParam = new iDB2Parameter(sName, parameterType, parameterSize); myParam.Value = parameterValue; myParam.Direction = paramDirection; return(myParam); }
public static iDB2Parameter CreateParameter(string name, object value, iDB2DbType dbType) { iDB2Parameter parm1 = new iDB2Parameter(); parm1.iDB2DbType = dbType; parm1.ParameterName = name; parm1.iDB2Value = value; return(parm1); }
public void AsignarParamProcAlmac(String Nombre, iDB2DbType TipoDato, Object Valor) { iDB2Parameter Parametro; Parametro = _Comando.CreateParameter(); Parametro.iDB2DbType = TipoDato; Parametro.ParameterName = Nombre; Parametro.Value = Valor; _Comando.Parameters.Add(Parametro); }
public void AsignarParamSalidaProcAlmac(String Nombre, iDB2DbType TipoDato, int Tamanio) { iDB2Parameter Parametro; Parametro = _Comando.CreateParameter(); Parametro.Direction = ParameterDirection.Output; Parametro.iDB2DbType = TipoDato; Parametro.ParameterName = Nombre; Parametro.Size = Tamanio; _Comando.Parameters.Add(Parametro); }
private static string SqlTypeToString(iDB2DbType type) { switch (type) { case iDB2DbType.iDB2VarChar: return("iDB2VarChar(250)"); case iDB2DbType.iDB2Char: return("iDB2Char(250)"); default: return(type.ToString()); } }
/// <summary> /// <para>Adds a new instance of an <see cref="iDB2Parameter"/> object to the command.</para> /// </summary> /// <param name="command">The <see cref="iDB2Command"/> to add the parameter.</param> /// <param name="name"><para>The name of the parameter.</para></param> /// <param name="idb2Type"><para>One of the <see cref="iDB2DbType"/> values.</para></param> /// <param name="size"><para>The maximum size of the data within the column.</para></param> /// <param name="direction"><para>One of the <see cref="ParameterDirection"/> values.</para></param> /// <param name="nullable"><para>A value indicating whether the parameter accepts <see langword="null"/> (<b>Nothing</b> in Visual Basic) values.</para></param> /// <param name="precision"><para>The maximum number of digits used to represent the <paramref name="value"/>.</para></param> /// <param name="scale"><para>The number of decimal places to which <paramref name="value"/> is resolved.</para></param> /// <param name="sourceColumn"><para>The name of the source column mapped to the DataSet and used for loading or returning the <paramref name="value"/>.</para></param> /// <param name="sourceVersion"><para>One of the <see cref="DataRowVersion"/> values.</para></param> /// <param name="value"><para>The value of the parameter.</para></param> #pragma warning disable 612, 618 public void AddParameter(DbCommand command, string name, iDB2DbType idb2Type, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value) { if (command == null) { throw new ArgumentNullException(nameof(command)); } iDB2Parameter param = base.CreateParameter(name, DbType.AnsiString, size, direction, nullable, precision, scale, sourceColumn, sourceVersion, value) as iDB2Parameter; if (param != null) { param.iDB2DbType = idb2Type; command.Parameters.Add(param); } }
private static iDB2Parameter[] GetParameters(Object parameters) { List <iDB2Parameter> listaParametro = new List <iDB2Parameter>(); if (parameters == null) { return(listaParametro.ToArray()); } foreach (PropertyInfo propiedad in parameters.GetType().GetProperties()) { dynamic valor = propiedad.GetValue(parameters, null); Type type = Nullable.GetUnderlyingType(propiedad.PropertyType); type = type ?? propiedad.PropertyType; object[] propertyList = propiedad.GetCustomAttributes(typeof(DBParameter), true); if (propertyList.Length > 0) { string nombreCampo = (propertyList[0] as DBParameter).NombreCampo.ToString(); string TipoDatoDB2 = (propertyList[0] as DBParameter).TipoDatoDB2.ToString(); iDB2DbType typeDate = new iDB2DbType(); switch (TipoDatoDB2) { case DBDataType.VarChar: typeDate = iDB2DbType.iDB2VarChar; break; case DBDataType.Char: typeDate = iDB2DbType.iDB2Char; break; case DBDataType.Decimal: typeDate = iDB2DbType.iDB2Decimal; break; case DBDataType.Numeric: typeDate = iDB2DbType.iDB2Numeric; break; case DBDataType.Date: typeDate = iDB2DbType.iDB2Date; break; case DBDataType.Integer: typeDate = iDB2DbType.iDB2Integer; break; } listaParametro.Add(type == typeof(DataTable) ? new iDB2Parameter { ParameterName = "@" + nombreCampo, Value = valor, iDB2DbType = typeDate } : new iDB2Parameter { ParameterName = "@" + nombreCampo, Value = valor }); } } return(listaParametro.ToArray()); }
/// <summary> /// Constructs the parameter using the DEDB2Paramater instance /// </summary> /// <param name="paramName">Name of the parameter.</param> /// <param name="paramValue">The parameter value.</param> /// <param name="paramType">Type of the parameter. Default iDB2DbType.Char</param> /// <param name="paramDirection">The parameter direction. Default ParameterDirection.Input</param> /// <returns>DEDB2Parameter instance with details</returns> protected DEDB2Parameter ConstructDB2Parameter(string paramName, string paramValue, int paramSize, iDB2DbType paramType = iDB2DbType.iDB2Char, ParameterDirection paramDirection = ParameterDirection.Input) { DEDB2Parameter parameterPiece = new DEDB2Parameter(); parameterPiece.ParamDirection = paramDirection; parameterPiece.ParamName = paramName; parameterPiece.ParamType = paramType; parameterPiece.ParamValue = paramValue; parameterPiece.ParamLength = paramSize; return(parameterPiece); }
public static KeyValuePair <string, KeyValuePair <iDB2DbType, object> > WithValueType(this string key, object value, iDB2DbType type) { return(new KeyValuePair <string, KeyValuePair <iDB2DbType, object> >(key, new KeyValuePair <iDB2DbType, object>(type, value))); }
/// <summary> /// Determines whether the specified given value is matching with given iDB2DbType. /// </summary> /// <param name="givenValueToCheck">The given value to check.</param> /// <param name="givenTypeToCheck">The given type to check.</param> /// <returns> /// <c>true</c> if the specified given value is matching with given iDB2DbType; otherwise, <c>false</c>. /// </returns> private bool HasValue(string givenValueToCheck, iDB2DbType givenTypeToCheck) { bool tempIsExists = false; if (givenValueToCheck.Equals(DBNull.Value)) { tempIsExists = true; } else { switch (givenTypeToCheck) { case iDB2DbType.iDB2VarChar: if (!(givenValueToCheck == null)) { tempIsExists = true; } else if (givenValueToCheck.Equals(string.Empty)) { tempIsExists = true; } else { tempIsExists = false; } break; //IsNumeric case iDB2DbType.iDB2Integer: if (!(givenValueToCheck == null)) { if (Information.IsNumeric(givenValueToCheck)) { tempIsExists = true; } else { tempIsExists = false; } } else { tempIsExists = false; } break; case iDB2DbType.iDB2Decimal: if (!(givenValueToCheck == null)) { if (Information.IsNumeric(givenValueToCheck)) { tempIsExists = true; } else { tempIsExists = false; } } else { tempIsExists = false; } break; case iDB2DbType.iDB2Double: if (!(givenValueToCheck == null)) { if (Information.IsNumeric(givenValueToCheck)) { tempIsExists = true; } else { tempIsExists = false; } } else { tempIsExists = false; } break; case iDB2DbType.iDB2SmallInt: if (!(givenValueToCheck == null)) { if (Information.IsNumeric(givenValueToCheck)) { tempIsExists = true; } else { tempIsExists = false; } } else { tempIsExists = false; } break; case iDB2DbType.iDB2BigInt: if (!(givenValueToCheck == null)) { if (Information.IsNumeric(givenValueToCheck)) { tempIsExists = true; } else { tempIsExists = false; } } else { tempIsExists = false; } break; //IsDate case iDB2DbType.iDB2Date: if (!(givenValueToCheck == null)) { if (Information.IsDate(givenValueToCheck)) { tempIsExists = true; } else { tempIsExists = false; } } else { tempIsExists = false; } break; default: if (!(givenValueToCheck == null)) { tempIsExists = true; } else { tempIsExists = false; } break; } } return(tempIsExists); }