System.Data.SqlClient Namespace SqlParameterCollection Class
Returns the number of parameters in the collection.
Script |
[ integer variable = ] SqlParameterCollection.Count |
variable |
The number of SqlParameter objects in the collection. |
ICollection.Count
The following example shows use of the Count property to set the upper bound of a loop that displays the name of each SqlParameter object in a given SqlParameterCollection.
public void CreateSqlParamColl ( SqlCommand myCmd ) {
SqlParameterCollection myParams = myCmd.Parameters;
string myParamNames = "";
for ( int i=0; i < myParams.Count; i++ ) {
myParamNames += myParams [ ].ToString ( ) + "\n";
}
MessageBox.Show ( myParamNames );
}
Public Sub CreateSqlParamColl ( myCmd As SqlCommand )
Dim myParams As SqlParameterCollection = myCmd.Parameters
Dim myParamNames As String = ""
Dim i As Integer
For i = 0 To myParams.Count - 1
myParamNames += myParams ( i ).ToString ( ) + ControlChars.Cr
Next i
MessageBox.Show ( myParamNames )
End Sub |
|
C# |
VB |
SqlParameterCollection Members