OracleParameter OracleParameter OracleParameter OracleParameter Class

Definition

Represents a parameter to an OracleCommand and optionally its mapping to a DataColumn. This class cannot be inherited.

public ref class OracleParameter sealed : System::Data::Common::DbParameter, ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Data.OracleClient.OracleParameter/OracleParameterConverter))]
public sealed class OracleParameter : System.Data.Common.DbParameter, ICloneable
type OracleParameter = class
    inherit DbParameter
    interface ICloneable
    interface IDbDataParameter
    interface IDataParameter
Public NotInheritable Class OracleParameter
Inherits DbParameter
Implements ICloneable
Inheritance
Attributes
Implements

Examples

The following example creates multiple instances of OracleParameter through the OracleParameterCollection within the OracleDataAdapter. These parameters are used to select data from the database and place the data in the DataSet. This example assumes that a DataSet and an OracleDataAdapter have already been created by using the appropriate schema, commands, and connection.

public void AddOracleParameters() 
 {
 // ...
 // create dataSet and adapter
 // ...
   adapter.SelectCommand.Parameters.Add("pEName", OracleType.VarChar, 80).Value = "Smith";
   adapter.SelectCommand.Parameters.Add("pEmpNo", OracleType.Int32).Value = 7369;
   adapter.Fill(dataSet);
 }

Public Sub AddOracleParameters()
    ' ...
    ' create dataSet and adapter
    ' ...
adapter.SelectCommand.Parameters.Add("pEName", OracleType.VarChar, 80).Value = "Smith"
adapter.SelectCommand.Parameters.Add("pEmpNo", OracleType.Int32).Value = 7369
adapter.Fill(dataSet)
End Sub 

Remarks

Parameter names are not case-sensitive.

When querying an Oracle database using the Microsoft OLE DB Provider for Oracle (MSDAORA) and the ODBC.NET Framework Data Provider, using the LIKE clause to query values in fixed-length fields may not return all expected matches. The reason is that when Oracle matches values for fixed-length fields in a LIKE clause, it matches the entire length of the string, including any padding trailing spaces. For example, if a table in an Oracle database contains a field named "Field1" that is defined as char(3), and you enter the value "a" into a row of that table, the following code will not return the row.

Dim queryString As String = "SELECT * FROM Table1 WHERE Field1 LIKE ?"  
Dim command As OleDbCommand = New OleDbCommand(queryString, connection)  
command.Parameters.Add("@p1", OleDbType.Char, 3).Value = "a"  
Dim reader As OleDbDataReader = command.ExecuteReader()  
string queryString = "SELECT * FROM Table1 WHERE Field1 LIKE ?";  
OleDbCommand command = new OleDbCommand(queryString, connection);  
command.Parameters.Add("@p1", OleDbType.Char, 3).Value = "a";  
OleDbDataReader reader = command.ExecuteReader();  

This is because Oracle stores the column value as "a " (padding "a", with trailing spaces, to the fixed field length of 3), which Oracle does not treat as a match for the parameter value of "a" in the case of a LIKE comparison of fixed-length fields.

To resolve this problem, append a percentage ("%") wildcard character to the parameter value ("a%"), or use an SQL = comparison instead.

Constructors

OracleParameter() OracleParameter() OracleParameter() OracleParameter()

Initializes a new instance of the OracleParameter class.

OracleParameter(String, Object) OracleParameter(String, Object) OracleParameter(String, Object) OracleParameter(String, Object)

Initializes a new instance of the OracleParameter class that uses the parameter name and an OracleParameter object.

OracleParameter(String, OracleType) OracleParameter(String, OracleType) OracleParameter(String, OracleType) OracleParameter(String, OracleType)

Initializes a new instance of the OracleParameter class that uses the parameter name and data type.

OracleParameter(String, OracleType, Int32) OracleParameter(String, OracleType, Int32) OracleParameter(String, OracleType, Int32) OracleParameter(String, OracleType, Int32)

Initializes a new instance of the OracleParameter class that uses the parameter name, data type, and length.

OracleParameter(String, OracleType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object) OracleParameter(String, OracleType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object) OracleParameter(String, OracleType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object) OracleParameter(String, OracleType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)

Initializes a new instance of the OracleParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

OracleParameter(String, OracleType, Int32, ParameterDirection, String, DataRowVersion, Boolean, Object) OracleParameter(String, OracleType, Int32, ParameterDirection, String, DataRowVersion, Boolean, Object) OracleParameter(String, OracleType, Int32, ParameterDirection, String, DataRowVersion, Boolean, Object) OracleParameter(String, OracleType, Int32, ParameterDirection, String, DataRowVersion, Boolean, Object)

Initializes a new instance of the OracleParameter class that uses the parameter name, data type, size, direction, source column, source version, and other properties.

OracleParameter(String, OracleType, Int32, String) OracleParameter(String, OracleType, Int32, String) OracleParameter(String, OracleType, Int32, String) OracleParameter(String, OracleType, Int32, String)

Initializes a new instance of the OracleParameter class that uses the parameter name, data type, length, and source column name.

Properties

DbType DbType DbType DbType

Gets or sets the DbType of the parameter.

Direction Direction Direction Direction

Gets or sets a value that indicates whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.

IsNullable IsNullable IsNullable IsNullable

Gets or sets a value that indicates whether the parameter accepts null values.

Offset Offset Offset Offset

Gets or sets the offset to the Value property.

OracleType OracleType OracleType OracleType

Gets or sets the OracleType of the parameter.

ParameterName ParameterName ParameterName ParameterName

Gets or sets the name of the OracleParameter.

Precision Precision Precision Precision

Gets or sets the maximum number of digits used to represent the Value property.

Scale Scale Scale Scale

Gets or sets the number of decimal places to which Value is resolved.

Size Size Size Size

Gets or sets the maximum size, in bytes, of the data within the column.

SourceColumn SourceColumn SourceColumn SourceColumn

Gets or sets the name of the source column mapped to the DataSet and used for loading or returning the Value

SourceColumnNullMapping SourceColumnNullMapping SourceColumnNullMapping SourceColumnNullMapping

Sets or gets a value which indicates whether the source column is nullable. This allows OracleCommandBuilder to correctly generate Update statements for nullable columns.

SourceVersion SourceVersion SourceVersion SourceVersion

Gets or sets the DataRowVersion to use when you load Value.

Value Value Value Value

Gets or sets the value of the parameter.

Methods

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ResetDbType() ResetDbType() ResetDbType() ResetDbType()

Resets the type associated with this OracleParameter.

ResetOracleType() ResetOracleType() ResetOracleType() ResetOracleType()

Resets the type associated with this OracleParameter.

ToString() ToString() ToString() ToString()

Gets a string that contains the ParameterName.

Explicit Interface Implementations

ICloneable.Clone() ICloneable.Clone() ICloneable.Clone() ICloneable.Clone()

For a description of this member, see Clone().

Applies to