I'm using LINQ to SQL to have interaction with my database and i'm attempting to perform the following to update just one row within 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();
should not this update the database using the change I designed to the row? or perhaps is there something I am missing?
thank you for any help
That code should work properly, so it should be elsewhere within the code or perhaps in the database itself.
Perhaps you have checked to make certain the column you're upgrading isn't read-only? As pst pointed out, are you currently using transactions?
A few things to check on:
- Is the code snippet utilizing the same
DataContext, meaning it isn't cut and copied and pasted from different techniques where you are instantiating new
- Is the
DataContext.ObjectTrackingEnabledproperty set to
true? It ought to be automatically, but when it's
DataContextwill not have the ability to carry out the update.