Click here to Skip to main content
11,920,353 members (51,457 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET LINQ
hello frds,

i have 2 table 1st Order and 2nd OrderProduct. both have PK and FK with OrderID relationship. now i want to update some field OrderProduct table but when i try to update that Amout Field nad NetAmount Field its give error. i m doing that using linq to Sql in asp dotnet.
here is error :
Value of member 'ID' of an object of type 'OrdersProduct' changed.

please help me.........

Thank To all in advance
Posted 18-May-12 4:31am
Edited 18-May-12 4:32am
Mohamed Mitwalli 18-May-12 9:36am
Share your code
Prasad_Kulkarni 18-May-12 9:38am
Post some code snippet Yatin

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The error you are getting is the result of modifying the key to the record.
You need to check your code and remove anything that will change the key. For example: if your code does something like this:

OrdersProduct currentProduct = {populate from database};
currentProduct = modifiedProduct;

That is bad -- especially if you are letting your user get access to the key field and modifying it!!!

Also make certain you're not modifying the field 'ID' anywhere yourself!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 415
1 phil.o 170
3 F-ES Sitecore 130
4 RyanDev 120
0 OriginalGriff 6,778
1 KrunalRohit 4,495
2 Sergey Alexandrovich Kryukov 3,203
3 George Jonsson 2,805
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web04 | 2.8.151120.1 | Last Updated 18 May 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100