简体   繁体   中英

Why does a typed dataset cause an insert rather than an update (causing primary key violation)?

I'm trying to use a dataset to update some rows in a database, simple.

I'm creating a typed dataset instance, disabling constraints, adding a few rows to one table and populating a few of the columns in the rows, including the primary key, with existing and correct primary key values. Yet, when I call update on the data adapter it's throwing a primary key violation .

I'm not providing values for every column, only those I want to update. Why does the adapter not recognise an update is required?

MyDataset dataSet = new MyDataset();
dataSet.EnforceConstraints = false;

只是因为您添加了()记录...这将它们标记为新的 ,它们将在更新时触发Insert语句。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM