To update a row in the database
- Query the database for the row to be updated.
- Make desired changes to member values in the resulting LINQ to SQL object.
- Submit the changes to the database.
// Query the database for the row to be updated.
var query =
from ord in db.Orders
where ord.OrderID == 11000
select ord;
// Execute the query, and change the column values
// you want to change.
foreach (Order ord in query)
{
ord.ShipName = "Mariner";
ord.ShipVia = 2;
// Insert any additional changes to column values.
}
// Submit the changes to the database.
try
{
db.SubmitChanges();
}
catch (Exception e)
{
Console.WriteLine(e);
// Provide for exceptions.
}
This entry was posted
on Thursday, September 24th, 2009 at 10:05 am and is filed under Uncategorized.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.