OracleParameterCollection.Add Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a OracleParameter to the OracleParameterCollection.
Overloads
Add(OracleParameter) |
Adds the specified OracleParameter to the OracleParameterCollection. |
Add(Object) |
Adds the specified OracleParameter object to the OracleParameterCollection. |
Add(String, OracleType) |
Adds an OracleParameter to the OracleParameterCollection given the parameter name and data type. |
Add(String, Object) |
Obsolete.
Adds an OracleParameter to the OracleParameterCollection given the parameter name and value. |
Add(String, OracleType, Int32) |
Adds an OracleParameter to the OracleParameterCollection given the parameter name, data type, and column length. |
Add(String, OracleType, Int32, String) |
Adds an OracleParameter to the OracleParameterCollection given the parameter name, data type, column length, and source column name. |
Add(OracleParameter)
Adds the specified OracleParameter to the OracleParameterCollection.
public:
System::Data::OracleClient::OracleParameter ^ Add(System::Data::OracleClient::OracleParameter ^ value);
public System.Data.OracleClient.OracleParameter Add (System.Data.OracleClient.OracleParameter value);
member this.Add : System.Data.OracleClient.OracleParameter -> System.Data.OracleClient.OracleParameter
override this.Add : System.Data.OracleClient.OracleParameter -> System.Data.OracleClient.OracleParameter
Public Function Add (value As OracleParameter) As OracleParameter
Parameters
- value
- OracleParameter
The OracleParameter to add to the collection.
Returns
A reference to the new OracleParameter object.
Exceptions
The OracleParameter specified in the value
parameter is already added to this or another OracleParameterCollection.
The value
parameter is null.
Examples
The following example creates an OracleParameterCollection, adds instances of OracleParameter to the collection, and returns a reference to the new OracleParameter.
public void CreateOracleParamColl() {
OracleCommand command = new OracleCommand(
"SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection);
OracleParameterCollection paramCollection = command.Parameters;
object parameter = new OracleParameter("pEmpNo", OracleType.Number);
int pIndex = paramCollection.Add(parameter);
}
Public Sub CreateOracleParamColl(connection As OracleConnection)
Dim command As New OracleCommand( _
"SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection)
Dim paramCollection As OracleParameterCollection = command.Parameters
Dim parameter As Object = New OracleParameter("pEmpNo", OracleType.Number)
Dim pIndex As Integer = paramCollection.Add(parameter)
End Sub
Applies to
Add(Object)
Adds the specified OracleParameter object to the OracleParameterCollection.
public:
virtual int Add(System::Object ^ value);
public:
override int Add(System::Object ^ value);
public int Add (object value);
public override int Add (object value);
abstract member Add : obj -> int
override this.Add : obj -> int
override this.Add : obj -> int
Public Function Add (value As Object) As Integer
Public Overrides Function Add (value As Object) As Integer
Parameters
- value
- Object
The OracleParameter object to add to the collection.
Returns
The index of the new OracleParameter object in the collection.
Implements
Applies to
Add(String, OracleType)
Adds an OracleParameter to the OracleParameterCollection given the parameter name and data type.
public:
System::Data::OracleClient::OracleParameter ^ Add(System::String ^ parameterName, System::Data::OracleClient::OracleType dataType);
public System.Data.OracleClient.OracleParameter Add (string parameterName, System.Data.OracleClient.OracleType dataType);
member this.Add : string * System.Data.OracleClient.OracleType -> System.Data.OracleClient.OracleParameter
override this.Add : string * System.Data.OracleClient.OracleType -> System.Data.OracleClient.OracleParameter
Public Function Add (parameterName As String, dataType As OracleType) As OracleParameter
Parameters
- parameterName
- String
The name of the parameter.
- dataType
- OracleType
One of the OracleType values.
Returns
A reference to the new OracleParameter object.
Examples
The following example creates an OracleParameterCollection, adds instances of OracleParameter to the collection, and returns a reference to the new OracleParameter.
public void CreateOracleParamColl() {
OracleCommand command = new OracleCommand(
"SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection);
OracleParameterCollection paramCollection = command.Parameters;
object parameter = new OracleParameter("pEmpNo", OracleType.Number);
int pIndex = paramCollection.Add(parameter);
}
Public Sub CreateOracleParamColl(connection As OracleConnection)
Dim command As New OracleCommand( _
"SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection)
Dim paramCollection As OracleParameterCollection = command.Parameters
Dim parameter As Object = New OracleParameter("pEmpNo", OracleType.Number)
Dim pIndex As Integer = paramCollection.Add(parameter)
End Sub
Applies to
Add(String, Object)
Caution
Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202
Adds an OracleParameter to the OracleParameterCollection given the parameter name and value.
public:
System::Data::OracleClient::OracleParameter ^ Add(System::String ^ parameterName, System::Object ^ value);
public System.Data.OracleClient.OracleParameter Add (string parameterName, object value);
[System.Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202", false)]
public System.Data.OracleClient.OracleParameter Add (string parameterName, object value);
member this.Add : string * obj -> System.Data.OracleClient.OracleParameter
[<System.Obsolete("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202", false)>]
override this.Add : string * obj -> System.Data.OracleClient.OracleParameter
Public Function Add (parameterName As String, value As Object) As OracleParameter
Parameters
- parameterName
- String
The name of the parameter.
- value
- Object
The Value of the OracleParameter to add to the collection.
Returns
A reference to the new OracleParameter object.
- Attributes
Exceptions
The value
parameter is not an OracleParameter.
Remarks
Use caution when using this overload of the Add method to specify integer parameter values. Because this overload takes a value
of type Object, you must convert the integral value to an Object type when the value is zero, as the following C# example demonstrates.
parameters.Add("pname", Convert.ToInt32(0));
If you do not perform this conversion, the compiler will assume you are attempting to call the OracleParameterCollection.Add
(string
, OracleType
) overload.
Applies to
Add(String, OracleType, Int32)
Adds an OracleParameter to the OracleParameterCollection given the parameter name, data type, and column length.
public:
System::Data::OracleClient::OracleParameter ^ Add(System::String ^ parameterName, System::Data::OracleClient::OracleType dataType, int size);
public System.Data.OracleClient.OracleParameter Add (string parameterName, System.Data.OracleClient.OracleType dataType, int size);
member this.Add : string * System.Data.OracleClient.OracleType * int -> System.Data.OracleClient.OracleParameter
override this.Add : string * System.Data.OracleClient.OracleType * int -> System.Data.OracleClient.OracleParameter
Public Function Add (parameterName As String, dataType As OracleType, size As Integer) As OracleParameter
Parameters
- parameterName
- String
The name of the parameter.
- dataType
- OracleType
One of the OracleType values.
- size
- Int32
The length of the column.
Returns
A reference to the new OracleParameter object.
Examples
The following example creates an OracleParameterCollection, adds an instance of OracleParameter to the collection, and returns a reference to the new OracleParameter.
public void CreateOracleParamColl(OracleConnection connection)
{
OracleCommand command = new OracleCommand(
"SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection);
OracleParameterCollection paramCollection = command.Parameters;
OracleParameter parameter = paramCollection.Add(
"pEmpNo", OracleType.Number, 4);
}
Public Sub CreateOracleParamColl(connection As OracleConnection)
Dim command As New OracleCommand( _
"SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection)
Dim paramCollection As OracleParameterCollection = command.Parameters
Dim parameter As OracleParameter = paramCollection.Add( _
"pEmpNo", OracleType.Number, 4)
End Sub
Applies to
Add(String, OracleType, Int32, String)
Adds an OracleParameter to the OracleParameterCollection given the parameter name, data type, column length, and source column name.
public:
System::Data::OracleClient::OracleParameter ^ Add(System::String ^ parameterName, System::Data::OracleClient::OracleType dataType, int size, System::String ^ srcColumn);
public System.Data.OracleClient.OracleParameter Add (string parameterName, System.Data.OracleClient.OracleType dataType, int size, string srcColumn);
member this.Add : string * System.Data.OracleClient.OracleType * int * string -> System.Data.OracleClient.OracleParameter
override this.Add : string * System.Data.OracleClient.OracleType * int * string -> System.Data.OracleClient.OracleParameter
Public Function Add (parameterName As String, dataType As OracleType, size As Integer, srcColumn As String) As OracleParameter
Parameters
- parameterName
- String
The name of the parameter.
- dataType
- OracleType
One of the OracleType values.
- size
- Int32
The length of the column.
- srcColumn
- String
The name of the source column.
Returns
A reference to the new OracleParameter object.
Examples
The following example creates an OracleParameterCollection, adds an instance of OracleParameter to the collection, and returns a reference to the new OracleParameter.
public void CreateOracleParamColl(OracleConnection connection)
{
OracleCommand command = new OracleCommand(
"SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection);
OracleParameterCollection paramCollection = command.Parameters;
OracleParameter parameter = paramCollection.Add(
"pEmpNo", OracleType.Number, 5, "EmpNo");
}
Public Sub CreateOracleParamColl(connection As OracleConnection)
Dim command As OracleCommand = _
New OracleCommand("SELECT Ename, DeptNo FROM Emp WHERE EmpNo = :pEmpNo", connection)
Dim paramCollection As OracleParameterCollection = command.Parameters
Dim parameter As OracleParameter = _
paramCollection.Add("pEmpNo", OracleType.Number, 5, "EmpNo")
End Sub