Probably the easiest way would be to do updates individually, inside the loop. This would mean that you prepare the SQL statement and create the parameters outside the loop and inside the loop you set the values for parameters and execute the statement.
Another option would be to gather the keys inside the loop and when done, use an
IN
comparison in the SQL statement. In other words something like
UPDATE mytable SET column = value WHERE keycolumn IN (@key1, @key2, @key3...)
To make this easier you can create the parameters and set their values inside the loop.
For a concrete example for the first option, have a look at
Properly executing database operations / Use prepare for repeated statements[
^]