Linq to sql c#: SubmitChanges() not updating the database?

The database is not updated, because you're submitting changes on the db DataContext, and the 'hold' you've provided through the constructor is not attached to that DataContext. Therefore, the db DataContext cannot track the changes you've made to the object You could try using DataContext. Attach or, even better, supply the form with the original data context the object was loaded from.

The database is not updated, because you're submitting changes on the db DataContext, and the 'hold' you've provided through the constructor is not attached to that DataContext. Therefore, the db DataContext cannot track the changes you've made to the object. You could try using DataContext.

Attach or, even better, supply the form with the original data context the object was loaded from.

– Nick Jun 8 at 5:59 @Nick, BAD idea, and still wouldn't solve your problem, since that way every class gets its own data context. Your formulation of using also scares me, because that creates even more data contexts. The best solution would be to determine 'units of work' (i.e.

Update an object) and create one data context for that unit of work, and pass said data context around to classes and methods that need it. You might want to look into dependency injection. – ErikHeemskerk Jun 8 at 6:17 I meant units of work like you described.

It's good to get a second opinion. Thanks for your advice. – Nick Jun 8 at 6:20 bingo.

I knew it had something to do with the datacontext. It wasn't adding up in my head how it would know what to use, considering. Still kind of new to this, trying to figure it out.

Thanks! – Sinaesthetic Jun 8 at 6:47.

ProductionSupervisor = (int)cboProductionSupervisor. LineNumber = (int) cboLineNumber. QASupervisor = (int) cboQASupervisor.

Flavor = (int) cboFlavorName. ContainerType = cboContainer. ProductSize = cboContainerSize.

Package = cboPackage. HoldQty = int. DateCode = mtbDateCode.

NonConformingItem = cboDefectiveComponent. NonConformance = cboDefectReason. FoundDuring = cboOccuredAt.

TestRequired = chkTestRequired. Comments = txaDescription. RootCause = txaRootCauseAnalysis.

Show(this, "Hold submitted! \n\nYou're hold number is " + thisHold.HoldID.ToString(),"Hold #" + thisHold.HoldID.ToString() + " created", MessageBoxButtons. Show(this, "Hold #" + thisHold.HoldID.ToString() + " updated.", thisHold.HoldID.ToString() + " updated", MessageBoxButtons.

If (ValidateEntry() && cert. LabTech = cert. LastEditBy = cert.

DateOpened = DateTime. LastEditDate = DateTime. LastEditBy = cert.

LastEditDate = DateTime. From a in db.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions