向数据库发送更新时,类型化数据集中的级联更改失败 [英] Cascaded changes in typed dataset fail when sending updates to database

查看:64
本文介绍了向数据库发送更新时,类型化数据集中的级联更改失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个强类型数据集,它使用ODBC连接到Postgres数据库。我一直在使用Visual Studio 2005中的数据集设计器来创建数据集,还使用tableadapters来发送更新和检索记录。数据集中有许多相关表,我设置了关系,以便更改和删除级联。

I have a strongly typed dataset that connects to a Postgres database using ODBC.  I've been using the dataset designer in Visual Studio 2005 to create the dataset and also use the tableadapters to send updates and retrieve records.  There are a number of related tables in the dataset and I have relationships set up so that changes and deletes are cascaded.

在数据库中,设置相同的关系以便更改级联。

In the database, the same relationships are set up such that changes are cascaded. 

我发现的是当我进行"更新"时从父表开始,添加/修改的记录插入正常,但数据库将更改级联到子表。然后当我尝试对子表进行更新时,我得到并发错误,因为数据集中子表的更改与数据库中发生的更改匹配。

What I'm finding is when I do an "update" and start with the parent tables the added/modified records are inserted fine but the database cascades the changes down to the child tables.  Then when I try to do an update on the child tables I get concurrency errors because the changes in the child tables in the dataset match the changes that have occurred in the database.

一种可能的解决方案是关闭数据库中的级联更新,但我认为这会导致初始更新失败,因为子记录不会有父记录。 。

One possible solution is to turn off the cascaded updates in the database but I think that will cause the inital updates to fail because the child records won't have parent records...

我认识到自己陷入困境......任何建议或意见都表示赞赏。

I recognize I've gotten myself into a sticky situation...any suggestions or comments are appreciated.

此外,还有什么方法可以判断由于级联更改而修改行的时间?

Also, is there any way to tell when a row is being modified due to a cascading change?

推荐答案

我有同样的问题。请参阅此主题http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/thread/0fc1128e-6e99-42cf-8862-5aae0bb758f0,了解我制作的一个丑陋的解决方法。

我使用"alter table xxx nocheck constraint"至少关闭RI的语句,因为我在数据库中永久关闭了级联,并且发现了关于"on delete"的信息。和"在更新时"因此,或许可以在TSQL命令中关闭所有RI和级联,包含事务内几个表的适配器更新。好奇你为这个问题做了什么! - 戴夫
I had this same issue . See this thread http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/thread/0fc1128e-6e99-42cf-8862-5aae0bb758f0 for an ugly workaround I made.

I use "alter table xxx nocheck constraint" statements to at least turn off RI which works since I turned off the cascading permanently inside the database and just found out about the "on delete" and "on update" clauses so may be able to just turn all the RI and cascading off in TSQL commands wrapped around adapter update of several tables inside a transaction. Curious what you did for this issue! - Dave


这篇关于向数据库发送更新时,类型化数据集中的级联更改失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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