This documentation is archived and is not being maintained.

OracleCommand.Parameters Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets the OracleParameterCollection.

[Visual Basic]
Public ReadOnly Property Parameters As OracleParameterCollection
public OracleParameterCollection Parameters {get;}
public: __property OracleParameterCollection* get_Parameters();
public function get Parameters() : OracleParameterCollection;

Property Value

The parameters of the SQL statement or stored procedure. The default is an empty collection.


When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. The user may be required to use escape character syntax if the stored procedure name contains any special characters. The command executes this stored procedure when you call one of the Execute methods.

The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an OracleCommand of CommandType.Text. In this case, named parameters must be used. For example:

SELECT * FROM Customers WHERE CustomerID = :pCustomerID

When using named parameters in an SQL statement or stored procedure, you must precede the parameter name with a colon (:). However, when referring to a named parameter elsewhere in your code (for example, when calling Add), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically.


[Visual Basic, C#, C++] The following example creates an OracleCommand and displays its parameters. To accomplish this, the method is passed an OracleConnection, a query string that is an SQL SELECT statement, and an array of OracleParameter objects.

[Visual Basic] 
Public Sub CreateMyOracleCommand(myConnection As OracleConnection, _
           mySelectQuery As String, myParamArray() As OracleParameter)

    Dim myCommand As New OracleCommand(mySelectQuery, myConnection)
    myCommand.CommandText = "SELECT * FROM Emp WHERE Job = :pJob AND Sal = :pSal"

    Dim j As Integer
    For j = 0 To myParamArray.Length - 1
    Next j

    Dim myMessage As String = ""
    Dim i As Integer
    For i = 0 To myCommand.Parameters.Count - 1
        myMessage += myCommand.Parameters(i).ToString() + ControlChars.Cr
    Next i

End Sub

public void CreateMyOracleCommand(OracleConnection myConnection,
string mySelectQuery, OracleParameter[] myParamArray)
   OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection);
   myCommand.CommandText = "SELECT * FROM Emp WHERE Job = :pJob AND Sal = :pSal";

   for (int j = 0; j < myParamArray.Length; j++)

   string myMessage = "";

   for (int i = 0; i < myCommand.Parameters.Count; i++) 
      myMessage += myCommand.Parameters[i].ToString() + "\n";


void CreateMyOracleCommand(OracleConnection* myConnection,
            String* mySelectQuery, OracleParameter* myParamArray[])
   OracleCommand* myCommand = new OracleCommand(mySelectQuery, myConnection);
   myCommand->CommandText = S"SELECT * FROM Emp WHERE Job = :pJob AND Sal = :pSal";

   for (int j = 0; j < myParamArray->Length; j++)

   String* myMessage = S"";

   for (int i = 0; i < myCommand->Parameters->Count; i++) 
      myMessage = String::Concat( myMessage, myCommand->Parameters->Item[i], S"\n" );


[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleCommand Class | OracleCommand Members | System.Data.OracleClient Namespace | OracleParameter