I have an int array with some values inside it, and its size is unknown (filled dynamically). I want to update a column in a database with this array (i.e. the column m of nth record in the database will be updated with nth element of the array). How can I achieve this? Should I update each record of the table in a separate sql similar to as follows:
for(int i = 0; i < array.Length; i++)
{
string sqlCommand = "UPDATE TABLENAME SET THECOLUMN = " + array[i] + " WHERE ID = " + (i+1);
// Execute the command
}
, or is there a more efficient or simplery way to do it?
PS: I am using ACCESS Database, connecting it to a (ASP.NET) website via C#
I would do it in one round trip
“Back and forths” to the database are fairly expensive, so you usually want your communications to be “chunky not chatty”.