DB2ParameterCollection.this Property
Gets or sets the DB2Parameter with a specified attribute.
Overload list
Name | Description |
---|---|
this(Integer) As DB2®Parameter | Gets or sets the DB2Parameter at the specified index. |
this(String) As DB2Parameter | Gets or sets the DB2Parameter with the specified name. |
Example
[Visual Basic, C#] The following example creates a DB2ParameterCollection , adds instances of DB2Parameter to the collection, displays the names of its DB2Parameter objects, and then clears the collection.
Note: [Visual Basic, C#] This example shows how to use one of the overloaded versions of
the this property (DB2ParameterCollection indexer).
For other examples that might be available, see the individual overload
topics.
[Visual Basic]
Public Sub CreateDB2ParamColl(myCommand As DB2Command)
Dim myParamCollection As DB2ParameterCollection = myCommand.Parameters
myParamCollection.Add("EMPNO", DB2Type.Char)
myParamCollection.Add("PHOTO_FORMAT", DB2Type.VarChar)
myParamCollection.Add("PICTURE", DB2Type.Blob)
Dim myParamNames As String = ""
Dim i As Integer
For i = 0 To myParamCollection.Count - 1
myParamNames += myParamCollection(i).ToString() + ControlChars.Cr
Next i
MessageBox.Show(myParamNames)
myParamCollection.Clear()
End Sub 'CreateDB2ParamColl
[C#]
public void CreateDB2ParamColl(DB2Command myCommand) {
DB2ParameterCollection myParamCollection = myCommand.Parameters;
myParamCollection.Add("EMPNO", DB2Type.Char);
myParamCollection.Add("PHOTO_FORMAT", DB2Type.VarChar);
myParamCollection.Add("PICTURE", DB2Type.Blob);
string myParamNames = "";
for (int i=0; i < myParamCollection.Count; i++)
myParamNames += myParamCollection[i].ToString() + "\n";
MessageBox.Show(myParamNames);
myParamCollection.Clear();
}