Newbie: SubmitChanges() doesn't seem to update my database? RRS feed

  • Question

  • Hello,

    Thanks for reviewing my question.  I am new to this LinqToSql but I think I understand the basics.  Everything seems to work.  However, it does not update the database after the SubmitChanges().  I locate a record, I modify and then call dc.SubmitChanges();  That's it.  What could I be doing wrong?

            String sConnection = ConfigurationManager.ConnectionStrings["LocalAYSOSQLServer"].ConnectionString;
            var dc = new AYSORegion210DBDataContext(sConnection);  // I originally had var dc = new AYSORegion210DBDataContext(); as well but same results
            var vol = dc.VOLUNTEERs.Single(v => v.VOLUNTEERAYSOID.ToLower() == sAYSOID.ToLower());
            vol.VOLUNTEERFIRSTNAME = "Hello world!";
            var vol2 = dc.VOLUNTEERs.Single(v => v.VOLUNTEERAYSOID.ToLower() == sAYSOID.ToLower());

           //vol2.VOLUNTEERFIRSTNAME  is set to the original 
    Many Thanks for your assistance with this matter.


    Friday, April 15, 2011 6:04 PM


All replies

  • Update:

    For kicks, I tried the example on another table and my code worked so the Submit on the other table must be failing.  I would be nice if there is a return value that is returned so you know if it in fact, worked.

    I am not sure what's wrong with the other table because I have one field that is a unique identifier with a default value of (newid()) and its the primary index.  Another field is the RowID that is int that is seeded with 1+, another date field with a default value of (getdate()).

    I wonder if any of those fields are causing an issue?


    Friday, April 15, 2011 6:42 PM
  • Check the data in the DB and the generated TSQL.

    Also create a new datacontext


    Friday, April 15, 2011 7:22 PM
  • This is what happens when you do not have a Primary Key set in the table, but seeming you say you have a primary key set can you post the AYSORegion210DBDataContext.designer.cs file here or just the part / class that is defined for VOLUNTEERs.
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, April 15, 2011 8:57 PM
  • Well, guess what happen?  I did what you said and it works.

    Thanks to you and the others for your help!!!  I appreciated it.


    Saturday, April 16, 2011 1:26 AM