错误:对于不返回任何键列信息的select命令,不支持update命令的动态sql生成 [英] Error:Dynamic sql generation for the update command is not supported against a select command that does not return any key column information

查看:151
本文介绍了错误:对于不返回任何键列信息的select命令,不支持update命令的动态sql生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我尝试在datagridview中完成更改时更新数据库,为此我添加了

Dim cb As New SqlCommandBuilder(adp)



adp.Update(ds,tablename)

在adp.update(ds,tablename)上收到错误:对于选择不支持更新命令的动态sql生成命令不返回任何键列信息

我可以知道原因plz ..

In my code i try to update database when changes done in datagridview,for this i have added
Dim cb As New SqlCommandBuilder(adp)

adp.Update(ds, "tablename")
At adp.update(ds,"tablename")am getting Error:Dynamic sql generation for the update command is not supported against a select command that does not return any key column information
May i know the reason plz..

推荐答案

You Have to Mention primary key in your Table.then before executing update command of dataApdapter you have to set update command of dataAdapter with CommandBuilder object like this 

--- create connection ----
SqlDataAdapter adp = new SqlDataAdapter();
SqlCommandBuilder bldr;

bldr=new SqlCommandBuilder(adp);
adp.UpdateCommand = bldr.GetUpdateCommand();
adp.Update(ds.Tables[0]);


您正在运行SELECT的表没有主键柱。它无法创建任何其他UPDATE或DETELE语句,因为您无法唯一标识表中的每条记录。
The table you're running the SELECT against doesn't have a primary key column. It cannot create any other UPDATE or DETELE statements because you have no way of uniquely identifying every single record in your table.


是,通过更新表中的主键可解决此问题,因为数据更新和删除的唯一数据列。
yes, this problem is resolved by update the primary key in your table because of data update and delete by unique data column.


这篇关于错误:对于不返回任何键列信息的select命令,不支持update命令的动态sql生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆