The following example searches for a
PgSqlParameter with a given
ParameterName within a
PgSqlParameterCollection. If the parameter exists, the example displays the name and index of the parameter. If the parameter does not exist, the example displays an error. This example assumes that a
PgSqlParameterCollection has already been created.
public void SearchPgSqlParams() {
// ...
// create PgSqlParameterCollection myParameters
// ...
if (!myParameters.Contains("DName"))
MessageBox.Show("ERROR: no such parameter in the collection");
else
MessageBox.Show("Name: " + myParameters["DName"].ToString() +
"Index: " + myParameters.IndexOf("DName").ToString());
}
Public Sub SearchPgSqlParams()
' ...
' create PgSqlParameterCollection myParameters
' ...
If Not myParameters.Contains("DName") Then
MessageBox.Show("ERROR: no such parameter in the collection")
Else
MessageBox.Show("Name: " & myParameters("DName").ToString() & _
"Index: " & myParameters.IndexOf("DName").ToString())
End If
End Sub