LinqDataSource 因未知原因引发 ChangeConflictException
我目前面临一个旧项目的奇怪问题。该项目使用 FormView 来编辑数据。 FormView 绑定到 LinqDataSource。更新编辑的对象后,我确实收到了
System.Data.Linq.ChangeConflictException - Row not found or change
异常。 我已经用谷歌搜索了一段时间,到目前为止我读过的帖子告诉我,这是一个并发问题。如果真的会有其他人同时更新数据,我会同意,但没有人这样做。
LinqDataSource 如下所示:
<asp:LinqDataSource ID="ldsFirma" runat="server" ContextTypeName="mynamespace.myDataContext"
EnableUpdate="True" TableName="Firmendatens" Where="Kennummer == @Kennummer"
OnSelecting="ldsFirma_Selecting" StoreOriginalValuesInViewState="False" OnUpdating="ldsFirma_Updating">
<WhereParameters>
<asp:Parameter Name="Kennummer" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
这是 FormView 的开始标记:
<asp:FormView ID="fvFirma" runat="server" DataKeyNames="Kennummer" DataSourceID="ldsFirma" ...
Update 由 ImageButton 引发:
我能做什么来解决这些问题。似乎并不是每一行都受此影响。几个小时前,我使用另一个 Web 应用程序连续更改了一个值。从那时起,我重建并清理了我目前遇到问题的网络应用程序好几次,但这并没有改变什么。
实际上我正在寻找一个可以设置为 false 的“DisableConcurrency”属性,但不幸的是 LDS 不提供这样的东西。
有什么建议吗?
I'm currently facing an odd problem with an old project. The project uses a FormView to edit data. The FormView is bound to a LinqDataSource. Upon updating the edited object, I do receive a
System.Data.Linq.ChangeConflictException - Row not found or change
exception.
I've googled for some time now and the posts I've read so far tell me, that this is a concurrency problem. I would agree, if there really would be somebody else updating the data in the meantime, but nobody does.
This is how the LinqDataSource looks like:
<asp:LinqDataSource ID="ldsFirma" runat="server" ContextTypeName="mynamespace.myDataContext"
EnableUpdate="True" TableName="Firmendatens" Where="Kennummer == @Kennummer"
OnSelecting="ldsFirma_Selecting" StoreOriginalValuesInViewState="False" OnUpdating="ldsFirma_Updating">
<WhereParameters>
<asp:Parameter Name="Kennummer" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
This is the opening tag of the FormView:
<asp:FormView ID="fvFirma" runat="server" DataKeyNames="Kennummer" DataSourceID="ldsFirma" ...
The Update is raised by an ImageButton:
What can I do to fix these. It seems that not every row is affected by this. I changed a value in a row several hours ago with another web application. Since then I've rebuild and cleaned the web application I'm currently having problems with several times, but that does not change a thing.
Actually I'm looking for a "DisableConcurrency" Property that I can set to false, but unfortunately the LDS does not provide such thing.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我找到了一个可行的解决方案。似乎无法在 LDS 上设置“DisableConcurrency”。但我可以修改 LinqToSql 表定义。我将“firmendatens”表中每一列的更新检查属性更改为“从不”
Ok, I've found a workable solution. It does not seem to be possible to set "DisableConcurrency" on a LDS. But I can modify the LinqToSql table defintion. I changed the Update Check Property of every column in the table 'firmendatens' to 'Never'