/** Adds the specified SQLRelayParameter to the collection. */ public Int32 Add(SQLRelayParameter value) { if (((SQLRelayParameter)value).ParameterName != null) { return(base.Add(value)); } else { throw new ArgumentException("parameter must be named"); } }
private void copyOutBindValues() { for (Int32 i = 0; i < Parameters.Count; i++) { SQLRelayParameter param = (SQLRelayParameter)Parameters[i]; if (param.Direction == ParameterDirection.Output) { param.Size = _sqlrcur.getOutputBindLength(param.ParameterName); switch (param.SQLRelayType) { case SQLRelayType.Clob: param.Value = _sqlrcur.getOutputBindClob(param.ParameterName); continue; case SQLRelayType.Blob: param.Value = _sqlrcur.getOutputBindBlob(param.ParameterName); continue; case SQLRelayType.Cursor: SQLRCursor cursor = _sqlrcur.getOutputBindCursor(param.ParameterName); if (cursor.fetchFromBindCursor()) { param.Value = new SQLRelayDataReader(_sqlrelaycon, cursor, false); } continue; } switch (param.DbType) { case DbType.AnsiString: case DbType.AnsiStringFixedLength: case DbType.String: case DbType.StringFixedLength: case DbType.Time: case DbType.Guid: param.Value = _sqlrcur.getOutputBindString(param.ParameterName); break; case DbType.Date: case DbType.DateTime: case DbType.DateTime2: case DbType.DateTimeOffset: Int16 year = 0; Int16 month = 0; Int16 day = 0; Int16 hour = 0; Int16 minute = 0; Int16 second = 0; Int32 microsecond = 0; String tz = null; Boolean isnegative = false; _sqlrcur.getOutputBindDate(param.ParameterName, out year, out month, out day, out hour, out minute, out second, out microsecond, out tz, out isnegative); param.Value = new DateTime(year, month, day, hour, minute, second, microsecond / 1000); break; case DbType.Binary: param.Value = _sqlrcur.getOutputBindBlob(param.ParameterName); break; case DbType.Boolean: param.Value = _sqlrcur.getOutputBindInteger(param.ParameterName); break; case DbType.Currency: case DbType.Decimal: case DbType.Single: case DbType.Double: case DbType.VarNumeric: param.Value = _sqlrcur.getOutputBindDouble(param.ParameterName); break; case DbType.Byte: case DbType.Int16: case DbType.Int32: case DbType.Int64: case DbType.SByte: case DbType.UInt16: case DbType.UInt32: case DbType.UInt64: param.Value = _sqlrcur.getOutputBindInteger(param.ParameterName); break; case DbType.Object: case DbType.Xml: param.Value = _sqlrcur.getOutputBindString(param.ParameterName); break; } } } }
private void bindParameters() { _sqlrcur.clearBinds(); for (Int32 i = 0; i < Parameters.Count; i++) { SQLRelayParameter param = (SQLRelayParameter)Parameters[i]; if (param.Direction == ParameterDirection.Input) { if (param.IsNull) { _sqlrcur.inputBind(param.ParameterName, null); continue; } switch (param.SQLRelayType) { case SQLRelayType.Clob: _sqlrcur.inputBindClob(param.ParameterName, Convert.ToString(param.Value), (UInt32)Convert.ToString(param.Value).Length); continue; case SQLRelayType.Blob: _sqlrcur.inputBindBlob(param.ParameterName, (Byte[])param.Value, (UInt32)((Byte[])param.Value).Length); continue; case SQLRelayType.Cursor: throw new NotSupportedException(); } switch (param.DbType) { case DbType.AnsiString: case DbType.AnsiStringFixedLength: case DbType.String: case DbType.StringFixedLength: case DbType.Time: case DbType.Guid: _sqlrcur.inputBind(param.ParameterName, Convert.ToString(param.Value)); continue; case DbType.Date: case DbType.DateTime: case DbType.DateTime2: case DbType.DateTimeOffset: DateTime dt = Convert.ToDateTime(param.Value); _sqlrcur.inputBind(param.ParameterName, Convert.ToInt16(dt.Year), Convert.ToInt16(dt.Month), Convert.ToInt16(dt.Day), Convert.ToInt16(dt.Hour), Convert.ToInt16(dt.Minute), Convert.ToInt16(dt.Second), Convert.ToInt16(dt.Millisecond) * 1000, null, false); continue; case DbType.Binary: _sqlrcur.inputBindBlob(param.ParameterName, (Byte[])param.Value, (UInt32)((Byte[])param.Value).Length); continue; case DbType.Boolean: _sqlrcur.inputBind(param.ParameterName, (Convert.ToBoolean(param.Value) == true) ? 1 : 0); continue; case DbType.Currency: case DbType.Decimal: case DbType.Single: case DbType.Double: case DbType.VarNumeric: _sqlrcur.inputBind(param.ParameterName, Convert.ToDouble(param.Value), 0, 0); continue; case DbType.Byte: case DbType.Int16: case DbType.Int32: case DbType.Int64: case DbType.SByte: case DbType.UInt16: case DbType.UInt32: case DbType.UInt64: _sqlrcur.inputBind(param.ParameterName, Convert.ToInt64(param.Value)); continue; case DbType.Object: case DbType.Xml: _sqlrcur.inputBind(param.ParameterName, Convert.ToString(param.Value)); continue; } } else if (param.Direction == ParameterDirection.Output) { switch (param.SQLRelayType) { case SQLRelayType.Clob: _sqlrcur.defineOutputBindClob(param.ParameterName); continue; case SQLRelayType.Blob: _sqlrcur.defineOutputBindBlob(param.ParameterName); continue; case SQLRelayType.Cursor: _sqlrcur.defineOutputBindCursor(param.ParameterName); continue; } switch (param.DbType) { case DbType.AnsiString: case DbType.AnsiStringFixedLength: case DbType.String: case DbType.StringFixedLength: case DbType.Time: case DbType.Guid: _sqlrcur.defineOutputBindString(param.ParameterName, param.Size); continue; case DbType.Date: case DbType.DateTime: case DbType.DateTime2: case DbType.DateTimeOffset: _sqlrcur.defineOutputBindDate(param.ParameterName); continue; case DbType.Binary: _sqlrcur.defineOutputBindBlob(param.ParameterName); continue; case DbType.Boolean: _sqlrcur.defineOutputBindInteger(param.ParameterName); continue; case DbType.Currency: case DbType.Decimal: case DbType.Single: case DbType.Double: case DbType.VarNumeric: _sqlrcur.defineOutputBindDouble(param.ParameterName); continue; case DbType.Byte: case DbType.Int16: case DbType.Int32: case DbType.Int64: case DbType.SByte: case DbType.UInt16: case DbType.UInt32: case DbType.UInt64: _sqlrcur.defineOutputBindInteger(param.ParameterName); continue; case DbType.Object: case DbType.Xml: _sqlrcur.defineOutputBindString(param.ParameterName, param.Size); continue; } } else if (param.Direction == ParameterDirection.InputOutput) { // FIXME: SQL Relay doesn't currently support in/out parameters throw new NotSupportedException(); } } }