を更新することはできません私は、データベース内のデータを編集したいが、私は行の任意の値を編集しようとした場合、エラーメッセージは、ID列
は、ID列「のProductID」
を更新できません後に登場データを更新しようとしています。私は初心者なので、どこにバグがあるのか分かりません。
<asp:SqlDataSource ID="Adventure" runat="server"
ConnectionString="<%$ ConnectionStrings:ConStrAdventure %>"
DeleteCommand="DELETE FROM [Production].[Product] WHERE [ProductID] = @ProductID"
InsertCommand="INSERT INTO [Production].[Product] ([ProductID], [Name], [ProductNumber], [MakeFlag], [FinishedGoodFlag], [Color], [SafetyStockLevel], [ReorderPoint], [StandardCost], [ListPrice], [Size], [SizeUnitMeasureCode], [WeightUnitMeasureCode], [Weight], [DaysToManufacture], [ProductLine], [Class], [Style], [ProductSubcategoryID], [ProductModelID], [SellStartDate], [SellEndDate], [DiscontinuedDate], [rowguid], [ModifiedDate]) VALUES (@ProductID, @Name, @ProductNumber, @MakeFlag, @FinishedGoodFlag, @Color, @SafetyStockLevel, @ReorderPoint, @StandardCost, @ListPrice, @Size, @SizeUnitMeasureCode, @WeightUnitMeasureCode, @Weight, @DaysToManufacture, @ProductLine, @Class, @Style, @ProductSubcategoryID, @ProductModelID, @SellStartDate, @SellEndDate, @DiscontinuedDate, @rowguid, @ModifiedDate) " SelectCommand="SELECT * FROM [Production].[Product]"
UpdateCommand="UPDATE [Production].[Product] SET [ProductID] = @ProductID,[Name] = @Name, [ProductNumber] = @ProductNumber, [MakeFlag] = @MakeFlag, [FinishedGoodsFlag] = @FinishedGoodsFlag, [Color] = @Color, [SafetyStockLevel] = @SafetyStockLevel, [ReorderPoint] = @ReorderPoint, [StandardCost] = @StandardCost, [ListPrice] = @ListPrice, [Size] = @Size, [SizeUnitMeasureCode] = @SizeUnitMeasureCode, [WeightUnitMeasureCode] = @WeightUnitMeasureCode, [Weight] = @Weight, [DaysToManufacture] = @DaysToManufacture, [ProductLine] = @ProductLine, [Class] = @Class, [Style] = @Style, [ProductSubcategoryID] = @ProductSubcategoryID, [ProductModelID] = @ProductModelID, [SellStartDate] = @SellStartDate, [SellEndDate] = @SellEndDate, [DiscontinuedDate] = @DiscontinuedDate, [rowguid] = @rowguid, [ModifiedDate] = @ModifiedDate WHERE [ProductID] = @ProductID">
The second part of the code here as image.
任意のアイデアを事前にありがとうございます。あなたのupdateコマンドが開始
私はこのコードの壁を理解できません。少なくとも読みやすいようにコードを書式化してください。エラーメッセージから判断すると、ID列を更新しているように見えます。あなたはそれをしたくないはずです。 – HoneyBadger
これを見てください:https://stackoverflow.com/questions/3947453/update-values-in-identity-column – Sankar
[ID列の値を更新](https://stackoverflow.com/questions/3947453/)の可能な複製identity-column内のupdate-values) – Sankar