asp.net.ph

SqlParameterCollection.IndexOf Method ( Object )

System.Data.SqlClient Namespace   SqlParameterCollection Class


Returns the location of a given SqlParameter within the collection.

[ VB ]
Overloads Public Function IndexOf ( _
   ByVal parameter As Object _
) As Integer

[ C# ]
public int IndexOf (
   object parameter
);

[ C++ ]
public: int IndexOf (
   Object* parameter
);

[ JScript ]
public function IndexOf (
   parameter : Object
) : int;

Parameters

parameter
The SqlParameter object to locate.

Return Value

The location of the SqlParameter within the collection.

Example

The following example first uses the Contains property to find an SqlParameter with a given Value within the Parameters collection of a specifed SqlCommand object. If the parameter exists, the example use the IndexOf method to display the index of the parameter; otherwise, the example displays an error.

public void SearchSqlParams ( SqlCommand myCmd ) {
   SqlParameterCollection myParams = myCmd.Parameters;
   if ( myParams.Contains ( ( Object ) myParam ) )
      MessageBox.Show ( "Match found on parameter " + 
         myParams.IndexOf ( ( Object ) myParam ).ToString ( ) );
   else
      MessageBox.Show ( "Sorry, no such parameter found in the collection" );

}
  C# VB

See Also

SqlParameterCollection Members   SqlParameterCollection.IndexOf 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