asp.net.ph

SqlParameterCollection.Contains Method ( String )

System.Data.SqlClient Namespace   SqlParameterCollection Class


Checks whether an SqlParameter with the specified name is in the collection.

[ VB ]
Overloads Public Function Contains ( _
   ByVal value As String _
) As Boolean

[ C# ]
public bool Contains (
   string value
);

[ C++ ]
public: bool Contains (
   String* value
);

[ JScript ]
public function Contains (
   value : String
) : Boolean

Parameters

value
The name of the parameter to retrieve.

Return Value

true if the collection contains the parameter; otherwise, false.

Implements

IDataParameterCollection.Contains

Example

The following example shows use of the Contains property to find an SqlParameter with a given ParameterName within the Parameters collection of a specifed SqlCommand object. If the parameter exists, the example displays the index of the parameter; otherwise, the example displays an error.

public void SearchSqlParams ( SqlCommand myCmd ) {
   SqlParameterCollection myParams = myCmd.Parameters;
   if ( myParams.Contains ( "@Model" ) )
      MessageBox.Show ( "Name: " + myParams [ "@Model" ].ToString ( ) + 
         "Index: " + myParams.IndexOf ( "@Model" ).ToString ( ) );
   else
      MessageBox.Show ( "Sorry, no such parameter found in the collection" );

}
  C# VB

See Also

SqlParameterCollection Members   SqlParameterCollection.Contains Overload List Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph