OleDbParameterCollection.Add Method (OleDbParameter)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Adds the specified OleDbParameter to the OleDbParameterCollection.

Namespace:   System.Data.OleDb
Assembly:  System.Data (in System.Data.dll)

public OleDbParameter Add(
	OleDbParameter value
)

Parameters

value
Type: System.Data.OleDb.OleDbParameter

The OleDbParameter to add to the collection.

Return Value

Type: System.Data.OleDb.OleDbParameter

The index of the new OleDbParameter object.

Exception Condition
ArgumentException

The OleDbParameter specified in the value parameter is already added to this or another OleDbParameterCollection.

ArgumentNullException

The value parameter is null.

The following example creates an OleDbParameterCollection and adds an OleDbParameter.

public void CreateParameters() 
{
    OleDbCommand command = new OleDbCommand(
        "SELECT * FROM Customers WHERE CustomerID = ?", connection);
    OleDbParameterCollection paramCollection = command.Parameters;
    OleDbParameter myParm = paramCollection.Add(
        new OleDbParameter("CustomerID", OleDbType.VarChar));
}

.NET Framework
Available since 1.1
Return to top
Show: