SqlParameterCollection.Remove Method

Definition

Overloads

Remove(SqlParameter)

Removes the specified SqlParameter from the collection.

Remove(Object)

Removes the specified SqlParameter from the collection.

Remove(SqlParameter)

Removes the specified SqlParameter from the collection.

public:
 void Remove(Microsoft::Data::SqlClient::SqlParameter ^ value);
public void Remove (Microsoft.Data.SqlClient.SqlParameter value);
override this.Remove : Microsoft.Data.SqlClient.SqlParameter -> unit
Public Sub Remove (value As SqlParameter)

Parameters

value
SqlParameter

A SqlParameter object to remove from the collection.

Exceptions

The parameter is not a SqlParameter.

The parameter does not exist in the collection.

Examples

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.

using Microsoft.Data.SqlClient;
using System.Xml;
using System.Data.Common;
using System.Windows.Forms;

public class Form1 : Form
{
    protected DataSet DataSet1;
    protected DataGrid dataGrid1;
    protected SqlCommand command;
    protected SqlParameter param;

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

Applies to

Remove(Object)

Removes the specified SqlParameter from the collection.

public:
 override void Remove(System::Object ^ value);
public override void Remove (object value);
override this.Remove : obj -> unit
Public Overrides Sub Remove (value As Object)

Parameters

value
Object

The object to remove from the collection.

Applies to