SubmitChangs not working for update

Anyone knows in which case the submitChanges will fail

I can insert, delete without any problem. only when i try to update, it will fail.

When i debug in, i can see the changed value before i call submit changes. but the changed value fail to save to DB. below is the sample code

var existingTrack = (
from s in db.Tracks
where s.ID == track.ID
select s).First();

existingTrack .Number = track.Number;
db.SubmitChanges();

thanks advance.



Answer this question

SubmitChangs not working for update

  • Philipp Lamp

    Everything is allright now. figure out its my silly mistake in TrackService . thanks all.


  • luai7

    thanks. maybe i should explain more about what i have done.

    my db Tracks is generated by SqlMetal and i just discovered some interesting fact.

    I test the SubmitChanges using a winform application and use

    TrackSample db = new TrackSample(ConfigurationManager.AppSettings["ConnectionString"]);

    (TrackSample is generated using SqlMetal )

    myApp -----------------------------------> TrackSample class

    |

    db.submitchnages(); (works!)

    the submistChanges doesn't work when i try to use 3 tier approach.

    myApp -------------------------------------------------> TrackService ----------------> TrackSample class

    | |

    service = new TrackServie();

    service.UpdateTrack(track); ..................

    db.submitChanges(); (not working )

    any idea i was thinking it might be the db context problem but couldn't figure out how.


  • Jamie Thomson

    I don't see any problem from the information you have posted. Here are some questions to ensure that the common issues are out of the way first:

    Is the class corresponding to db.Tracks generated by SqlMetal or DLinq designer If not, then is the value you are setting to different from the one before

    You may want to limit the test to just the update and then call db.GetChangeText() to see what SQL is generated. Perhaps you can share the mapping for the class corresponding to db.Tracks.

    HTH

    Dinesh



  • SubmitChangs not working for update