Export (0) Print
Expand All

SqlParameterCollection.Remove Method

Removes the specified SqlParameter from the collection.

[Visual Basic]
Public Overridable Sub Remove( _
   ByVal value As Object _
) Implements IList.Remove
[C#]
public virtual void Remove(
 object value
);
[C++]
public: virtual void Remove(
 Object* value
);
[JScript]
public function Remove(
   value : Object
);

Parameters

value
A SqlParameter object to remove from the collection.

Implements

IList.Remove

Exceptions

Exception Type Condition
InvalidCastException The parameter is not a SqlParameter.
SystemException The parameter does not exist in the collection.

Example

[Visual Basic, C#, C++] 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.

[Visual Basic] 
Public Sub SearchSqlParams()
    ' ...
    ' create SqlCommand myCmd and SqlParameter myParameter
    ' ...
    If myCmd.Parameters.Contains(myParameter) Then
        myCmd.Parameters.Remove(myParameter)
    End If
End Sub 'SearchSqlParams

[C#] 
public void SearchSqlParams() {
    // ...
    // create SqlCommand myCmd and SqlParameter myParameter
    // ...
    if (myCmd.Parameters.Contains(myParameter))
        myCmd.Parameters.Remove(myParameter);
 }

[C++] 
public:
void SearchSqlParams() {
    // ...
    // create SqlCommand myCmd and SqlParameter myParameter
    // ...
    if (myCmd->Parameters->Contains(myParameter))
        myCmd->Parameters->Remove(myParameter);
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

SqlParameterCollection Class | SqlParameterCollection Members | System.Data.SqlClient Namespace

Show:
© 2014 Microsoft