operator not defined for System.Data.SqlClient.SqlConnection and System.Data.SqlClient.SqlConnection
- by Beta033
i hope i'm just doing something wrong here.
Ideally i'm trying to open the connection, open a transaction
execute a ton of prebuilt sqlstatements (with parameters) against this connection
then close the connection. ideally all in the same batch.
It's easy enough to wrap this all in a for loop, however i'd like to use the forEach function of the list generic to set the connection as it'll probably be faster than my implementation of calling List.Item(i) in the loop but i get some strange errors.
Dim sqlStatements As List(Of SqlCommand) = New List(Of SqlCommand)
Dim conn As SqlClient.SqlConnection = New SqlConnection("...")
sqlStatements.Item(0).Connection = conn
'Works
sqlStatements.ForEach(Function(ByRef cmd As SqlCommand) cmd.Connection = conn)
'ERROR: Operator '=' is not defined for types
'System.Data.SqlClient.SqlConnection'
'and 'System.Data.SqlClient.SqlConnection
What does this error really mean?