none
SQL DB entry not updated RRS feed

  • Question

  • Hi i'm still learning all these.

    Have a piece of code which doesn't update the database entry. This is the simplified version, i can step into these lines in VS 2012. But when i close VS 2012, opens the Sql management studio, the fields are still holding old values.

    Must be something simple, but just cannot figure out. Any help appreciated.

    if (MyGlobals.customerEntities.TableMfis.Any(x => x.personName == "John"))
    {
        // find this entry in DB
        TableMfi bMfi = MyGlobals.customerEntities.TableMfis.Single(y => y.personName == "John");

        // m_date[0] is sth. like "11-04-2013"
        System.DateTime todayDate = Convert.ToDateTime(m_date[0]);
                           
        // update
        bMfi.mfiDate = todayDate;
        bMfi.mfiValue = m_mfi[0];
                           
        MyGlobals.customerEntities.SaveChanges();
    }

    Thursday, November 7, 2013 4:53 PM

All replies

  • Hi ningji;

    Can you post the connection string found in app.config/webconfig, if the connection string has a username and password change them to xxx so that they do not show this information.

    Also is this a Code First or Database First project.

      


    Fernando (MCSD)

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

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, November 7, 2013 5:06 PM
  • Hello ningji,

    Have you solved this issue?

    If it is, it is appreciated that you share it.

    If not, could you please share some more information regarding this issue like the connection string mentioned by Fernando and the table structure so that we can help you better?

    Regards. 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 12, 2013 7:24 AM
    Moderator