none
Why data do not get save to database ? RRS feed

  • Question

  • Dear all,

    I have the following code snipets

     if (isUpdateMode) //The Row is edited
                {
    
                    CATEGORIES TempEmp = (from c in qCtx.CATEGORIES
    
                                          where c.Id == objThemeToEdit.Id
    
                                        select c).First();
    
    
                    FrameworkElement element_1 = dataGridTheme.Columns[2].GetCellContent(e.Row);
    
                    if (element_1.GetType() == typeof(TextBox))
                    {
                        var name = ((TextBox)element_1).Text;
                        objThemeToEdit.Categorie = name;
                        qCtx.SaveChanges(); 
    
                    }
    
                }       

    When I am updating a Grid cell, it seems that only the datasource gets updated but not the database after the SaveChanges gets called.
    Any idea why data do not get change in database ?

    regards

    serge


    Your knowledge is enhanced by that of others.

    Monday, May 28, 2012 2:30 PM

Answers

  • As I stated in my last post, "I do not see where you are updating the context before saving to the database.",  and this is what I would expect to see, TempEmp .Categorie = name;, note that TempEmp is the result of the query and is stored in the context and when you modified it the results is what you wanted after saving too the database. 

    My post answered your question.... 

       


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, May 28, 2012 4:39 PM

All replies

  •   

    I do not see where you are updating the context before saving to the database.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, May 28, 2012 3:15 PM
  • Grrr find the mistake in:

    objThemeToEdit.Categorie = name;
    it shold be :

    TempEmp .Categorie = name;


    Your knowledge is enhanced by that of others.


    Monday, May 28, 2012 4:12 PM
  • As I stated in my last post, "I do not see where you are updating the context before saving to the database.",  and this is what I would expect to see, TempEmp .Categorie = name;, note that TempEmp is the result of the query and is stored in the context and when you modified it the results is what you wanted after saving too the database. 

    My post answered your question.... 

       


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, May 28, 2012 4:39 PM
  • ok good then.


    Your knowledge is enhanced by that of others.

    Monday, May 28, 2012 4:42 PM