Olvasás angol nyelven Szerkesztés

Megosztás a következőn keresztül:


OleDbParameterCollection.Item[] Property

Definition

Gets or sets the OleDbParameter with a specified attribute.

Overloads

Item[String]

Gets or sets the OleDbParameter with the specified name.

Item[Int32]

Gets or sets the OleDbParameter at the specified index.

Item[String]

Source:
OleDbParameterCollection.cs
Source:
OleDbParameterCollection.cs
Source:
OleDbParameterCollection.cs

Gets or sets the OleDbParameter with the specified name.

C#
[System.ComponentModel.Browsable(false)]
public System.Data.OleDb.OleDbParameter this[string parameterName] { get; set; }

Parameters

parameterName
String

The name of the parameter to retrieve.

Property Value

The OleDbParameter with the specified name.

Attributes

Exceptions

The name specified does not exist.

Examples

The following example searches for an OleDbParameter with a given ParameterName within an OleDbParameterCollection. 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 OleDbParameterCollection has already been created.

C#
public void SearchParameters()
{
    // ...
    // create OleDbParameterCollection parameters
    // ...
    if (!parameters.Contains("Description"))
        Console.WriteLine("ERROR: no such parameter in the collection");
    else
        Console.WriteLine("Name: " + parameters["Description"].ToString() +
            "Index: " + parameters.IndexOf("Description").ToString());
}

See also

Applies to

.NET 10 (package-provided) és más verziók
Termék Verziók
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Item[Int32]

Source:
OleDbParameterCollection.cs
Source:
OleDbParameterCollection.cs
Source:
OleDbParameterCollection.cs

Gets or sets the OleDbParameter at the specified index.

C#
[System.ComponentModel.Browsable(false)]
public System.Data.OleDb.OleDbParameter this[int index] { get; set; }

Parameters

index
Int32

The zero-based index of the parameter to retrieve.

Property Value

The OleDbParameter at the specified index.

Attributes

Exceptions

The index specified does not exist.

Examples

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

C#
public void CreateParamCollection(OleDbCommand command)
{
    OleDbParameterCollection paramCollection = command.Parameters;
    paramCollection.Add("@CategoryName", OleDbType.Char);
    paramCollection.Add("@Description", OleDbType.Char);
    paramCollection.Add("@Picture", OleDbType.Binary);
    string parameterNames = "";
    for (int i=0; i < paramCollection.Count; i++)
        parameterNames += paramCollection[i].ToString() + "\n";
    Console.WriteLine(parameterNames);
    paramCollection.Clear();
}

See also

Applies to

.NET 10 (package-provided) és más verziók
Termék Verziók
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)