可以将 ADO.NET SQLCommandBuilder 与组合键一起使用吗?
我有一个包含 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为你的问题是复合键。 根据文档,主键不必是单个列。 不过,自动生成语句还需要其他限制。 尝试通读此文档以验证您是否没有错过任何事情。
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.