DB2 V9.7 for Linux, UNIX, and Windows

DB2ParameterCollection.IndexOf 方法

获取 DB2Parameter 在集合中的位置。

重载列表

名称 描述
IndexOf(Object) As Integer Implements IList.IndexOf

获取具有指定参数名的 DB2Parameter 对象在集合中的位置。

IndexOf(String) As Integer Implements IDataParameterCollection.IndexOf

获取具有特定参数名的 DB2Parameter 在集合中的位置。

示例

[Visual Basic, C#] 以下示例在 DB2ParameterCollection 中搜索带有给定 DB2Parameter.NameDB2Parameter。如果该参数存在,那么示例将显示它的名称和下标。如果该参数不存在,那么示例将显示错误。此示例假定已经创建了 DB2ParameterCollection 集合。

注: [Visual Basic, C#] 此示例说明如何使用 IndexOf 的某个重载版本。有关其他可用的示例,请参阅各个重载主题。
[Visual Basic]
Public Sub SearchDB2Params()
    ' ...
    ' create DB2ParameterCollection 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 'SearchDB2Params

[C#]
public void SearchDB2Params() {
    // ...
    // create DB2ParameterCollection 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());
 }