prosit
asked on
Passing a variable number of parameters to a function
Hi,
Why doesn't this work:
sqlInsert:
Why doesn't this work:
For Each strline As String In my852File.Split(vbCrLf)
Dim line852() = strline.Split(",")
Dim parms(24) As SqlParameter
parms(cnt) = New SqlParameter("@" + ColNames(cnt), line852(cnt))
clsData.SQLInsert(parms)
' parms above is hightlighted with this error: Value of type '1-dimensional array of System.Data.SqlClient.SqlParameter' cannot be converted to 'System.Collections.Generic.List(Of System.Data.SqlClient.SqlParameter)'.
cnt += 1
Next
sqlInsert:
Public Function SQLInsert(ByVal ParameterValues As List(Of SqlParameter)) As Boolean
Try
Dim ConnectionStr As New SqlConnection(myVars.GetSQLString)
Dim sqlCMD As New SqlCommand()
For Each parm As SqlParameter In ParameterValues
sqlCMD.Parameters.Add(parm)
Next
sqlCMD.CommandType = CommandType.StoredProcedure
sqlCMD.ExecuteNonQuery()
Return True
Catch ex As Exception
Return False
End Try
End Function
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER