I have a loop in a vb.net project that makes dynamic SQL which I want to have parameterized. I was planning to call the sub that runs the SQL statement every 10 records because I thought I heard doing it 1 at a time is slower. So how do I commit the SQL query every 10 records if the parameters are changing each time through the loop? I realized I can just append _x.ToString to the variable names and have 20 variables in the list, but I didn't know if there's a "proper" way of doing this that I'm overlooking. Very stripped down code example is below
For _x As Integer = 0 To _dataset.Tables(_x).Rows.Count - 1
_sql &= "INSERT INTO test (col1, col2) VALUES (@col1, @col2) "
_parameters.Add(new parameter("@col1", <variable data>) // changes every time through loop
_parameters.Add(new parameter("@col2", <variable data>) // changes every time through loop
If _x Mod 10 = 0 Then
Call executeSQL(_sql, _parameters)
End If
Next