Export (0) Print
Expand All

SqlParameterCollection.RemoveAt Method

Removes the specified SqlParameter from the collection.

Overload List

Removes the specified SqlParameter from the collection using a specific index.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub RemoveAt(Integer) Implements IList.RemoveAt
[C#] public virtual void RemoveAt(int);
[C++] public: virtual void RemoveAt(int);
[JScript] public function RemoveAt(int);

Removes the specified SqlParameter from the collection using the parameter name.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Sub RemoveAt(String) Implements IDataParameterCollection.RemoveAt
[C#] public virtual void RemoveAt(string);
[C++] public: virtual void RemoveAt(String*);
[JScript] public function RemoveAt(String);

Example

[Visual Basic, C#, C++] The following example looks for a SqlParameter with a given ParameterName within 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, C#, C++] Note   This example shows how to use one of the overloaded versions of RemoveAt. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub SearchSqlParams()
    ' ...
    ' create SqlCommand myCmd
    ' ...
    If myCmd.Parameters.Contains("Description") Then
        myCmd.Parameters.RemoveAt("Description")
    End If
End Sub 'SearchSqlParams

[C#] 
public void SearchSqlParams() {
    // ...
    // create SqlCommand myCmd
    // ...
    if (myCmd.Parameters.Contains("Description"))
        myCmd.Parameters.RemoveAt("Description");
 }

[C++] 
public:
void SearchSqlParams() {
    // ...
    // create SqlCommand myCmd
    // ...
    if (myCmd->Parameters->Contains(S"Description"))
        myCmd->Parameters->RemoveAt(S"Description");
 }

[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.

See Also

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

Show:
© 2014 Microsoft