Solution for Store update, insert, or delete statement affected an unexpected number of rows (0)

来源:互联网 发布:软件详细设计说明书 编辑:程序博客网 时间:2024/06/07 07:37

When i create CYTestDeptTrainWebsite via MVC3, i got blocking issue: Store update, insert, or delete statement affected an unexpected number of rows (0)...

type the solution on here:


In the Album class, you've defined [Bind(Exclude = "AlbumId")] on the class, which means that the code won't try and bind the AlbumId from the form. Which is fine, except that on the edit page, you're passing in a populated Album, which is presumably being populated using binding, which is of course ignoring the Album Id, so the AlbumId of the object passed into the edit method, is always 0, which throws a misleading concurrency error, because no rows are affected, because there's no album with ID of 0.

If you remove the bind/exclude attribute, then the edit page works as expected.


原创粉丝点击