1

I have a batch process that reads data from multiple tables into a dataset based on a common key. I then build a second dataset of the destination data querying on the same key.

At this point I have two Datasets that are structurally identical (from a table/column layout perspective). I then have a process that adds any row that exists in source to the destination dataset. In addition, the process will attempt to update certain columns based on the common key as well.

The problem seems to come in when the DataAdapter.UPDATE command is called with existing rows that it needs to update. Error: System.InvalidOperationException was unhandled Message="The table specified in the SELECT statement does not contain a unique key or identifier column, or the SELECT statement does not include all of the key columns."

Since I have no way of controlling what the PK is on the destination DB, is there a way to tell the Adapter what the key is for this particular update? I have "custom" set the primary keys for each DataTable in the Dataset.

This is a non user interfacing batch process and its perf requirements are quite low. (to explain the use of datasets, etc)

Any Thoughts?

4

2 回答 2

1

分析数据库并查看正在触发哪些查询。从 Profiler 复制查询并尝试手动执行它们。如果它们失败了,那么问题出在 sql 上,错误来自 db,只是被传递给您的应用程序。

这至少应该告诉你问题是否是由于数据库中缺少真正的 PK 引起的。

于 2009-01-18T08:14:30.690 回答
0

您必须像以前一样为数据集中的每个表设置 PK。我认为适配器没有办法自己弄清楚PK是什么。如果有并且有人知道,我会全神贯注。

于 2008-11-10T17:17:08.287 回答