SqlParameterCollection.Remove Method (SqlParameter)

 
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.

Removes the specified SqlParameter from the collection.

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

public void Remove(
	SqlParameter value
)

Parameters

value
Type: System.Data.SqlClient.SqlParameter

A SqlParameter object to remove from the collection.

Exception Condition
InvalidCastException

The parameter is not a SqlParameter.

SystemException

The parameter does not exist in the collection.

The following example searches for a SqlParameter object in a SqlParameterCollection collection. If the parameter exists, the example removes it. This example assumes that a SqlParameterCollection collection has already been created by a SqlCommand.

public void SearchSqlParams() 
{
    // ...
    // create SqlCommand command and SqlParameter param
    // ...
    if (command.Parameters.Contains(param))
        command.Parameters.Remove(param);
}

.NET Framework
Available since 2.0
Return to top
Show: