as i said SqlParameterCollection is not ment to initialise. It is a helping Class for the Command and Parameters objects.
if you wan to create a collection then you can create an array Collection of the Parameters.
here is just a small example:
Public Sub AddSqlParameter(ByVal cmd As System.Data.SqlClient.SqlCommand, _
ByVal params As System.Collections.ArrayList)
Dim parser As System.Collections.IEnumerator
parser = params.GetEnumerator()
While parser.MoveNext()
cmd.Parameters.Add(parser.Current)
End While
End Sub
Now, we can pass the Parameters like this:
Dim ar As New ArrayList
Dim sqlprm1 As New SqlParameter
Dim sqlprm2 As New SqlParameter
Dim sqlprm2 As New SqlParameter
sqlprm1.Value = field1
sqlprm2.Value = field2
sqlprm3.Value = field3
ar.Add(sqlprm1)
ar.Add(sqlprm2)
ar.Add(sqlprm3)
Dim myCommand As New SqlCommand
AddSqlParameter(myCommand, ar)
We help with .NET Development. Visit us and share your part!