Editare

Partajați prin


OracleParameterCollection.Item[] Property

Definition

Gets or sets the OracleParameter with a specified attribute.

Overloads

Item[String]

Gets or sets the OracleParameter with the specified name.

Item[Int32]

Gets or sets the OracleParameter at the specified index.

Item[String]

Gets or sets the OracleParameter with the specified name.

public:
 property System::Data::OracleClient::OracleParameter ^ default[System::String ^] { System::Data::OracleClient::OracleParameter ^ get(System::String ^ parameterName); void set(System::String ^ parameterName, System::Data::OracleClient::OracleParameter ^ value); };
public System.Data.OracleClient.OracleParameter this[string parameterName] { get; set; }
member this.Item(string) : System.Data.OracleClient.OracleParameter with get, set
Default Public Property Item(parameterName As String) As OracleParameter

Parameters

parameterName
String

The name of the parameter to retrieve.

Property Value

The OracleParameter with the specified name.

Exceptions

The name specified does not exist.

Examples

The following example searches for an OracleParameter with a given ParameterName within an OracleParameterCollection. If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that an OracleParameterCollection has already been created.

public void SearchOracleParams()
{
    // ...
    // create OracleParameterCollection parameters
    // ...
    if (!parameters.Contains("DName"))
        Console.WriteLine("ERROR: no such parameter in the collection");
    else
        Console.WriteLine("Name: " + parameters["DName"].ToString() +
            "Index: " + parameters.IndexOf("DName").ToString());
}
Public Sub SearchOracleParams()
    ' ...
    ' create OracleParameterCollection parameters
    ' ...
    If Not parameters.Contains("DName") Then
        Console.WriteLine("ERROR: no such parameter in the collection")
    Else
        Console.WriteLine("Name: " & parameters("DName").ToString() & _
            "Index: " & parameters.IndexOf("DName").ToString())
    End If
End Sub

Applies to

Item[Int32]

Gets or sets the OracleParameter at the specified index.

public:
 property System::Data::OracleClient::OracleParameter ^ default[int] { System::Data::OracleClient::OracleParameter ^ get(int index); void set(int index, System::Data::OracleClient::OracleParameter ^ value); };
public System.Data.OracleClient.OracleParameter this[int index] { get; set; }
member this.Item(int) : System.Data.OracleClient.OracleParameter with get, set
Default Public Property Item(index As Integer) As OracleParameter

Parameters

index
Int32

The zero-based index of the parameter to retrieve.

Property Value

The OracleParameter at the specified index.

Exceptions

The index specified does not exist.

Examples

The following example creates an OracleParameterCollection, adds instances of OracleParameter to the collection, displays the names of its OracleParameter objects, and then clears the collection.

public void CreateOracleParamColl(OracleCommand command)
{
    OracleParameterCollection paramCollection = command.Parameters;
    paramCollection.Add("pDName", OracleType.VarChar);
    paramCollection.Add("pLoc", OracleType.VarChar);
    string parameterNames = "";
    for (int i=0; i < paramCollection.Count; i++)
        parameterNames += paramCollection[i].ToString() + "\n";
    Console.WriteLine(parameterNames);
    paramCollection.Clear();
}
Public Sub CreateOracleParamColl(command As OracleCommand)
    Dim paramCollection As OracleParameterCollection = command.Parameters
    paramCollection.Add("pDName", OracleType.Varchar)
    paramCollection.Add("pLoc", OracleType.Varchar)
    Dim parameterNames As String = ""
    Dim i As Integer
    For i = 0 To paramCollection.Count - 1
        parameterNames &= paramCollection(i).ToString() & ControlChars.Cr
    Next i
    Console.WriteLine(parameterNames)
    paramCollection.Clear()
End Sub

Applies to