获取一个指示集合中是否存在 DB2Parameter 对象的值。
| 名称 | 描述 |
|---|---|
| Contains(Object) As Boolean Implements IList.Contains | 获取一个指示集合中是否存在 DB2Parameter 对象的值。 |
| Contains(String) As Boolean Implements IDataParameterCollection.Contains | 获取一个指示集合中是否存在具有指定参数名的 DB2Parameter 对象的值。 |
[Visual Basic, C#] 以下示例在 DB2ParameterCollection 中搜索带有给定 DB2Parameter.ParameterName 的 DB2Parameter。如果该参数存在,那么示例将显示它的名称和下标。如果该参数不存在,那么示例将显示错误。此示例假定已经创建了 DB2ParameterCollection。
[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());
}