how to update SQL using C# code example
Example: how to update database using sql in c#
using (var sqlConnection = new SqlConnection(config.ConnectionString))
{
foreach(var position in positions)
{
var sql =
$"UPDATE BillOfMaterial SET Position = '{pos}' WHERE Creator = '{position.Creator}' AND Idx = '{position.Idx}' AND ArtNumber = '{position.ArtNumber}'";
using (var sqlCommand = new SqlCommand(sql,sqlConnection))
{
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
sqlConnection.Close();
}
}
}