locked
Entity Framework to update table in SQL SERVER 2008 RRS feed

  • Question

  • Hi,

    I am using ADO .NET and trying to update a column value in a table in SQL SERVER 2008 database. However the value is not updating. Even though it's update when I debug it in C# code. Here is my code:

    using (ADONETClass context = new ADONETClass())
            {
                List<Invoices> list = context.Invoices.ToList<Invoices>();
                foreach (Invoices b in list)
                {
                    b.status = 0;
                }
            }

    Now I debugged the code and saw that context.Invoices.ToList()[0].status is indeed set to zero. But when the program finished running, I open the SQL management studio and status value there was still 0. Not sure what is going on? Am I missing something?

    Thanks

    Amare


    • Edited by Amare1982 Sunday, April 22, 2012 11:00 PM
    Sunday, April 22, 2012 10:17 PM

Answers

  • I found the solution. We need to put context.saveChanges() in the end.
    • Marked as answer by Amare1982 Monday, April 23, 2012 12:11 AM
    Sunday, April 22, 2012 10:59 PM