| Oracle® Data Provider for .NET Developer's Guide Release 9.2.0.4 Part Number B10961-01 |
|
Oracle.DataAccess.Client Namespace, 16 of 30
An OracleParameterCollection class represents a collection of all parameters relevant to an OracleCommand object and their mappings to DataSet columns.
Object
MarshalByRefObject
OracleParameterCollection
// C# public sealed class OracleParameterCollection : MarshalByRefObject, IDataParameterCollection, IList, ICollection, IEnumerable
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
The position of an OracleParameter added into the OracleParameterCollection is the binding position in the SQL statement. Position is 0-based and is used only for positional binding. If named binding is used, the position of an OracleParameter in the OracleParameterCollection is ignored.
// C# string conStr = "User Id=scott;Password=tiger;Data Source=oracle"; // Create the OracleConnection OracleConnection con = new OracleConnection(conStr); con.Open(); // Create the OracleCommand OracleCommand cmd = new OracleCommand(); cmd.Connection = con; // Create OracleParameter OracleParameter [] prm = new OracleParameter[3]; // Bind parameters prm[0] = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, 1234, ParameterDirection.Input); prm[1] = cmd.Parameters.Add("paramEname", OracleDbType.Varchar2, "Client", ParameterDirection.Input); prm[2] = cmd.Parameters.Add("paramDeptNo", OracleDbType.Decimal, 10, ParameterDirection.Input); cmd.CommandText = "insert into emp(empno, ename, deptno) values(:1, :2, :3)"; cmd.ExecuteNonQuery(); // Remove OracleParameter objects from the collection cmd.Parameters.Clear(); // Dispose OracleCommand object cmd.Dispose(); // Close and Dispose OracleConnection object con.Close(); con.Dispose();
Namespace: Oracle.DataAccess.Client
Assembly: Oracle.DataAccess.dll
OracleParameterCollection members are listed in the following tables:
OracleParameterCollection static methods are listed in Table 4-92.
| Methods | Description |
|---|---|
|
|
Inherited from |
OracleParameterCollection properties are listed in Table 4-93.
| Name | Description |
|---|---|
|
Specifies the number of |
|
|
Gets and sets the |
OracleParameterCollection public methods are listed in Table 4-94.
OracleParameterCollection static methods are listed in Table 4-95.
| Methods | Description |
|---|---|
|
|
Inherited from |
OracleParameterCollection properties are listed in Table 4-96.
| Name | Description |
|---|---|
|
Specifies the number of |
|
|
Gets and sets the |
This property specifies the number of OracleParameter objects in the collection.
// C# public int Count {get;}
The number of OracleParameter objects.
ICollection
Default = 0
Item gets and sets the OracleParameter object.
This property gets and sets the OracleParameter object at the index specified by the supplied parameterIndex.
This property gets and sets the OracleParameter object using the parameter name specified by the supplied parameterName.
This property gets and sets the OracleParameter object at the index specified by the supplied parameterIndex.
// C# public object Item[int parameterIndex] {get; set;}
An object.
IList
IndexOutOfRangeException - The supplied index does not exist.
The OracleParameterCollection class is a zero-based index.
This property gets and sets the OracleParameter object using the parameter name specified by the supplied parameterName.
// C# public OracleParameter Item[string parameterName] {get; set;};
An OracleParameter.
IDataParameterCollection
IndexOutOfRangeException - The supplied parameter name does not exist.
OracleParameterCollection public methods are listed in Table 4-97.
Add adds objects to the collection.
This method adds the supplied object to the collection.
This method adds the supplied OracleParameter object to the collection.
This method adds an OracleParameter object to the collection using the supplied name and object value.
This method adds an OracleParameter object to the collection using the supplied name and database type.
This method adds an OracleParameter object to the collection using the supplied name, database type, and direction.
This method adds an OracleParameter object to the collection using the supplied name, database type, parameter value, and direction.
This method adds an OracleParameter object to the collection using the supplied name, database type, size, parameter value, and direction.
This method adds an OracleParameter object to the collection using the supplied name, database type, and size.
This method adds an OracleParameter object to the collection using the supplied name, database type, size, and source column.
This method adds an OracleParameter object to the collection using the supplied name, database type, size, direction, null indicator, precision, scale, source column, source version, and parameter value.
This method adds the supplied object to the collection.
// C# public int Add(object obj);
The index at which the new OracleParameter is added.
IList
InvalidCastException - The supplied obj cannot be cast to an OracleParameter object.
This method adds the supplied OracleParameter object to the collection.
// C# public OracleParameter Add(OracleParameter paramObj);
The newly created OracleParameter object which was added to the collection.
This method adds an OracleParameter object to the collection using the supplied name and object value
// C# public OracleParameter Add(string name, object val);
The newly created OracleParameter object which was added to the collection.
This method adds an OracleParameter object to the collection using the supplied name and database type.
// C# public OracleParameter Add(string name, OracleDbType dbType);
The newly created OracleParameter object which was added to the collection.
This method adds an OracleParameter object to the collection using the supplied name, database type, and direction.
// C# public OracleParameter Add(string name, OracleDbType dbType, ParameterDirection direction);
name
Specifies the parameter name.
dbType
Specifies the datatype of the OracleParameter.
direction
Specifies the OracleParameter direction.
The newly created OracleParameter object which was added to the collection.
This method adds an OracleParameter object to the collection using the supplied name, database type, parameter value, and direction.
// C# public OracleParameter Add(string name, OracleDbType dbType, object val, ParameterDirection dir);
name
Specifies the parameter name.
dbType
Specifies the datatype of the OracleParameter.
val
Specifies the OracleParameter value.
dir
Specifies one of the ParameterDirection values.
The newly created OracleParameter object which was added to the collection.
// C# ... OracleParameter prm = new OracleParameter(); prm = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, 1234, ParameterDirection.Input); cmd.CommandText = "insert into NumTable(numcol) values(:1)"; cmd.ExecuteNonQuery(); ...
This method adds an OracleParameter object to the collection using the supplied name, database type, size, parameter value, and direction.
// C# public OracleParameter Add(string name, OracleDbType dbType, int size, object val, ParameterDirection dir;
name
Specifies the parameter name.
dbType
Specifies the datatype of the OracleParameter.
size
Specifies the size of OracleParameter.
val
Specifies the OracleParameter value.
dir
Specifies one of the ParameterDirection values.
The newly created OracleParameter object which was added to the collection.
This method adds an OracleParameter object to the collection using the supplied name, database type, and size.
// C# public OracleParameter Add(string name, OracleDbType dbType, int size);
name
Specifies the parameter name.
dbType
Specifies the datatype of the OracleParameter.
size
Specifies the size of OracleParameter.
The newly created OracleParameter object which was added to the collection.
// C# ... OracleParameter prm = new OracleParameter(); prm = cmd.Parameters.Add("param1", OracleDbType.Decimal, 10); prm.Direction = ParameterDirection.Input; prm.Value = 1111; cmd.CommandText = "insert into NumTable(numcol) values(:1)"; cmd.ExecuteNonQuery(); ...
This method adds an OracleParameter object to the collection using the supplied name, database type, size, and source column.
// C# public OracleParameter Add(string name, OracleDbType dbType, int size, string srcColumn);
name
Specifies the parameter name.
dbType
Specifies the datatype of the OracleParameter.
size
Specifies the size of OracleParameter.
srcColumn
Specifies the name of the source column.
An OracleParameter.
This method adds an OracleParameter object to the collection using the supplied name, database type, size, direction, null indicator, precision, scale, source column, source version, and parameter value.
// C# public OracleParameter Add(string name, OracleDbType dbType, int size, ParameterDirection dir, bool isNullable, byte precision, byte scale, string srcColumn, DataRowVersion version, object val);
name
Specifies the parameter name.
dbType
Specifies the datatype of the OracleParameter.
size
Specifies the size of OracleParameter.
dir
Specifies one of the ParameterDirection values.
isNullable
Specifies if the parameter value can be null.
precision
Specifies the precision of the parameter value.
scale
Specifies the scale of the parameter value.
srcColumn
Specifies the name of the source column.
version
Specifies one of the DataRowVersion values.
val
Specifies the parameter value.
The newly created OracleParameter object which was added to the collection.
ArgumentException - The type of supplied val does not belong to the type of Value property in any of the ODP.NET Types.
This method removes all the OracleParameter objects from the collection.
// C# public void Clear();
IList
// C# ... OracleParameter [] prm = new OracleParameter[3]; prm[0] = cmd.Parameters.Add("paramEmpno", OracleDbType.Decimal, 1234, ParameterDirection.Input); prm[1] = cmd.Parameters.Add("paramEname", OracleDbType.Varchar2, "Client", ParameterDirection.Input); prm[2] = cmd.Parameters.Add("paramDeptNo", OracleDbType.Decimal, 10, ParameterDirection.Input); cmd.CommandText = "insert into emp(empno, ename, deptno) values(:1,:2, :3)"; cmd.ExecuteNonQuery(); // This method removes all the parameters from the parameter collection. cmd.Parameters.Clear(); ...
Contains indicates whether the supplied object exists in the collection.
This method indicates whether the supplied object exists in the collection.
This method indicates whether an OracleParameter object exists in the collection using the supplied string.
This method indicates whether the supplied object exists in the collection.
// C# public bool Contains(object obj)
A bool that indicates whether or not the OracleParameter specified is inside the collection.
IList
InvalidCastException - The supplied obj is not an OracleParameter object.
Returns true if the collection contains the OracleParameter object; otherwise, returns false.
... prm = cmd.Parameters.Add("param1", OracleDbType.Decimal, 1234, ParameterDirection.Input); if (cmd.Parameters.Contains((Object)prm)) // This method removes a particular parameter from the parameter collection. cmd.Parameters.Remove((Object) prm); ...
This method indicates whether an OracleParameter object exists in the collection using the supplied string.
// C# public bool Contains(string name);
Returns true if the collection contains the OracleParameter object with the specified parameter name; otherwise, returns false.
IDataParameterCollection
... prm = cmd.Parameters.Add("param1", OracleDbType.Decimal, 1234, + ParameterDirection.Input); if (cmd.Parameters.Contains((Object)prm)) // This method removes a particular parameter from the parameter collection. cmd.Parameters.Remove((Object) prm); ...
This method copies OracleParameter objects from the collection, starting with the supplied index to the supplied array.
// C# public void CopyTo(Array array, int index);
ICollection
IndexOf returns the index of the OracleParameter object in the collection.
This method returns the index of the OracleParameter object in the collection.
This method returns the index of the OracleParameter object with the specified name in the collection.
This method returns the index of the OracleParameter object in the collection.
// C# public int IndexOf(object obj);
Returns the index of the OracleParameter object in the collection.
IList
InvalidCastException - The supplied obj cannot be cast to an OracleParameter object.
Returns the index of the supplied OracleParameter obj in the collection.
This method returns the index of the OracleParameter object with the specified name in the collection.
// C# public int IndexOf(String name);
Returns the index of the supplied OracleParameter in the collection.
IDataParameterCollection
This method inserts the supplied OracleParameter object to the collection at the specified index.
// C# public void Insert(int index, object obj);
IList
An InvalidCastException is thrown if the supplied obj cannot be cast to an OracleParameter object.
This method removes the supplied OracleParameter from the collection.
// C# public void Remove(object obj);
IList
InvalidCastException - The supplied obj cannot be cast to an OracleParameter object.
... prm = cmd.Parameters.Add("param1", OracleDbType.Decimal, 1234, ParameterDirection.Input); if (cmd.Parameters.Contains((Object)prm)) // This method removes a particular parameter from the parameter collection. cmd.Parameters.Remove((Object) prm); ...
RemoveAt removes the OracleParameter object from the collection by location.
This method removes from the collection the OracleParameter object located at the index specified by the supplied index.
This method removes from the collection the OracleParameter object specified by the supplied name.
This method removes from the collection the OracleParameter object located at the index specified by the supplied index.
// C# public void RemoveAt(int index);
IList
This method removes from the collection the OracleParameter object specified by the supplied name.
// C# public void RemoveAt(String name);
IDataParameterCollection
|
|
![]() Copyright © 2002, 2003 Oracle Corporation. All Rights Reserved. |
|