开发者

LinqDataSource throws a ChangeConflictException for an unknown reason

开发者 https://www.devze.com 2023-02-16 11:26 出处:网络
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

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 dat开发者_JAVA技巧a 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?


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'

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号