SqlDataAdapter 更新
任何人都可以帮助我为什么当我使用 sqlDataadapter 和连接查询进行更新时会发生此错误
多个基表不支持动态 SQL 生成。
Can any one help me why this error occurs when i update using sqlDataadapter with join query
Dynamic SQL generation is not supported against multiple base tables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的数据集的主查询中有一个“连接”(TableAdapter 中的第一个查询)。当主查询通过联接在查询中引用多个表时,您无法自动为 TableAdapter 生成插入/更新/删除逻辑。设计者不够聪明,无法弄清楚在这种情况下您想要将更新发送到哪个表,这就是您收到错误消息的原因。
解决方案。确保您的主查询仅引用您希望设计器为其编写插入/更新/删除代码的表。您的辅助查询可以引用任意数量的表。
You have a "join" in your main query for your dataset (The first one in the TableAdapter with a check by it). You can't automatically generate insert/update/delete logic for a TableAdapter when the main query has multiple tables referenced in the query via a join. The designer isn't smart enough to figure out which table you want to send updates to in that case, that is why you get the error message.
Solution. Ensure that your main query only references the table you want the designer to write insert/update/delete code for. Your secondary queries may reference as many tables as you want.
在这种情况下,我试图在数据行中设置标识列的值。只需删除为身份列设置值的代码,它就会起作用。
我的场景:
数据库:
uin [主要,身份]
姓名
地址
每当我尝试设置数据行(“uin”)时就会发生错误。但与 datarow("name") 和 datarow("address") 配合得很好。
希望它也适合你
It was in the case that i was trying to set value for identity column in my datarow. Simply i deleted the code to set value for identity column and it will work.
My Scenario:
Database:
uin [primary, identity]
name
address
Whenever i tried to set the datarow("uin") the error occurs. But works fine with datarow("name") and datarow("address").
Hope it works for you too