次の方法で共有


OleDbParameterCollection.IndexOf メソッド (String)

指定したパラメータ名の OleDbParameter の、コレクション内での位置を取得します。

Overloads Public Overridable Function IndexOf( _
   ByVal parameterName As String _) As Integer Implements IDataParameterCollection.IndexOf
[C#]
public virtual int IndexOf(stringparameterName);
[C++]
public: virtual int IndexOf(String* parameterName);
[JScript]
public function IndexOf(
   parameterName : String) : int;

パラメータ

  • parameterName
    検索する OleDbParameter オブジェクトの名前。

戻り値

OleDbParameter の、コレクション内での位置。

実装

IDataParameterCollection.IndexOf

使用例

[Visual Basic, C#, C++] OleDbParameterCollection コレクション内で、指定した ParameterNameOleDbParameter を検索する例を次に示します。目的のパラメータが存在する場合は、そのパラメータの名前とインデックスを表示します。目的のパラメータが存在しない場合は、エラーを表示します。この例では、 OleDbParameterCollection コレクションが既に作成されていることを前提にしています。

 
Public Sub SearchOleDbParams()
    ' ...
    ' create OleDbParameterCollection myParameters
    ' ...
    If Not myParameters.Contains("Description") Then
        MessageBox.Show("ERROR: no such parameter in the collection")
    Else
        MessageBox.Show("Name: " & myParameters("Description").ToString() & _
                        "Index: " & myParameters.IndexOf("Description").ToString())
    End If
End Sub 'SearchOleDbParams

[C#] 
public void SearchOleDbParams() {
    // ...
    // create OleDbParameterCollection myParameters
    // ...
    if (!myParameters.Contains("Description"))
       MessageBox.Show("ERROR: no such parameter in the collection");
    else
       MessageBox.Show("Name: " + myParameters["Description"].ToString() +
                 "Index: " + myParameters.IndexOf("Description").ToString());
 }

[C++] 
public:
void SearchOleDbParams() {
    // ...
    // create OleDbParameterCollection myParameters
    // ...
    if (!myParameters->Contains(S"Description"))
       MessageBox::Show(S"ERROR: no such parameter in the collection");
    else
       MessageBox::Show(String::Format( S"Name: {0}Index: {1}",
          myParameters->Item[S"Description"], __box(myParameters->IndexOf(S"Description"))));
 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

OleDbParameterCollection クラス | OleDbParameterCollection メンバ | System.Data.OleDb 名前空間 | OleDbParameterCollection.IndexOf オーバーロードの一覧