I am using LINQ to SQL to interact with my database and I am trying to do the following to update a single row in the database:
DataClassesDataContext dataContext = new DataClassesDataContext();
TableName aRow = (from rows in dataContext.TableNames where rows.x == y select rows).Single();
aRow.attribute = "something";
dataContext.SubmitChanges();
shouldn’t this update the database with the change I made to the row?
or is there something I’m missing?
thanks for any help
A couple of things to check:
DataContext, meaning it’s not cut and pasted from different methods where you’re instantiating newDataContextinstances?DataContext.ObjectTrackingEnabledproperty set totrue? It should be by default, but if it’sfalsethen yourDataContextwon’t be able to perform the update.