更新记录中的问题 [英] Problem in update record

查看:93
本文介绍了更新记录中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好frds,

我有2个表1st Order和2nd OrderProduct.两者都具有带有OrderID关系的PK和FK.现在,我想更新某些字段OrderProduct表,但是当我尝试更新该Amout字段和NetAmount字段时,其给定错误.我正在使用linq to asp dotnet中的Sql进行操作.
这是错误:
类型为"OrdersProduct"的对象的成员"ID"的值已更改.


请帮助我.........


预先致谢全部

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

推荐答案

您收到的错误是由于修改了记录的键所致.
您需要检查代码并删除所有会更改密钥的内容.例如:如果您的代码执行以下操作:

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;



这很不好-尤其是如果您要让用户访问关键字段并对其进行修改!!!

还请确保您自己不在任何地方修改"ID"字段!



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!


这篇关于更新记录中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆