0

Wondering if anyone can see why i am getting the error "Row not found or changed." when i perform this LINQ query.

The row is there and the data is being picked up ok, but when it comes to update i am getting the error mentioned above.

aboDataDataContext dc = new aboDataDataContext();

        var orders = dc.GetOrderToAcknowledges;

        //Get the TWE Order ID and Store in DB.
        foreach (var order in orders)
        {
            int orderId = dc.amzOrders.Single(o => o.amzOrderId == order.amzOrderId).id;
            DateTime now = DateTime.Now;

            GetTWEOrderID(orderId, now.ToString());

            amzOrder orderUpdate = dc.amzOrders.Single(o => o.id == orderId);
            orderUpdate.acknowledged = true;
            orderUpdate.lastUpdate = Convert.ToDateTime(now);

            dc.SubmitChanges();

        }
thatuxguy
  • 2,418
  • 7
  • 30
  • 51

2 Answers2

0

Make sure that the designer shows the exact same fields for your entities like your database schema.

This error often occurs when there are changes in the database that were not updated in the entities.

For example a table column might be changed to allow for null values but the entities were not updated to recognize the change.

Jens H
  • 4,590
  • 2
  • 25
  • 35
0

Worked it out, looked into what DaveHogan said, and moved it around a bit also updated things a little...

var ou = dc.amzOrders.Single(o => o.amzOrderId == order.amzOrderId);
int orderId = ou.id;
DateTime now = DateTime.Now;

ou.acknowledged = true;
ou.lastUpdate = Convert.ToDateTime(now);

dc.SubmitChanges();

GetTWEOrderID(orderId, now.ToString());
thatuxguy
  • 2,418
  • 7
  • 30
  • 51