Using linq2sql I’m trying to take the string in txtOilChange and update the oilChange integer in the car table of the white fusion.
I know my code below is wrong but what do I need to change?
using (DataClasses1DataContext db = new DataClasses1DataContext())
{
var o = (from c in db.cars
where c.carDesc == "White Fusion"
select c).First();
txtOilChange.Text = o.oilChange.ToString();
db.SubmitChanges();
}
If you’re trying to update the record it looks like the assignment statement is reversed.
This:
Should be:
For better error handling consider using the
TryParsemethod: