可以将 ADO.NET SQLCommandBuilder 与组合键一起使用吗?

发布于 2024-07-08 00:17:15 字数 501 浏览 6 评论 0原文

我有一个包含 6 列的数据库表。 主键是由 6 列中的 5 列组成的复合键,

我尝试使用 SqlClient.SqlCommandBuilder.GetDeleteCommand 来删除该行。

但是我收到以下错误:

“System.InvalidOperationException:动态 SQL 生成 对于不支持的 SelectCommand,DeleteCommand 不受支持 返回任何关键列信息。”

SelectCommmand 包含表中的所有列:

SELECT  TABLENAME.COL1, TABLENAME.COL2, TABLENAME.COL3, 
        TABLENAME.COL4, TABLENAME.COL5, TABLENAME.COL6
FROM TABLENAME  

问题可能是复合键吗?

I have a database table with 6 columns. The primary key is a composite key made up of 5 of the 6 columns

I am trying to use the SqlClient.SqlCommandBuilder.GetDeleteCommand to delete the row.

However I am getting the following error:

"System.InvalidOperationException : Dynamic SQL generation for the
DeleteCommand is not supported against a SelectCommand that does not
return any key column information."

The SelectCommmand contains all the columns in the table:

SELECT  TABLENAME.COL1, TABLENAME.COL2, TABLENAME.COL3, 
        TABLENAME.COL4, TABLENAME.COL5, TABLENAME.COL6
FROM TABLENAME  

Could the problem be the composite key?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

窝囊感情。 2024-07-15 00:17:15

我不认为你的问题是复合键。 根据文档,主键不必是单个列。 不过,自动生成语句还需要其他限制。 尝试通读此文档以验证您是否没有错过任何事情。

I don't think your problem is the composite key. According to the documentation, the primary key does not have to be a single column. There are other limitations that are required to automatically generate statements though. Try reading through this document to verify that you haven't missed anything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文