通过具有记录的数据适配器更新数据集中的问题 [英] Problem to update in dataset through data adapter with exsting records

查看:101
本文介绍了通过具有记录的数据适配器更新数据集中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用现有行通过数据适配器更新数据集.
我这样写:

I want to update in dataset through data adapter with existing row.
I have written like this:

SqlConnection con = new SqlConnection(connectionstring);
                    SqlCommand cmd = new SqlCommand("select * from students where student_id='s0001'", con);
                    SqlDataAdapter da = new SqlDataAdapter(cmd.CommandText, con);
                    SqlCommandBuilder cmdbuilder = new SqlCommandBuilder(da);
                    cmdbuilder.SetAllValues = true;
                    DataSet ds = new DataSet();
                    da.Fill(ds, "contacts");
                    // da.UpdateCommand = cmdbuilder.GetUpdateCommand(); 
                    ds.Tables[0].Rows[0]["name"] = "surendra";
                    ds.Tables[0].Rows[0]["mobile"] = "9090595512";
                    ds.Tables[0].Rows[0]["city"] = "Bhubaneswar";
                    cmdbuilder.SetAllValues = true;
                    da.Update(ds, "students");



在catch块中抛出的错误是:



The Error thrown me in catch block is:

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

推荐答案



这里''m提供了通过SqlDataAdapter更新数据的链接

http://forums.asp.net/t/1222425.aspx/1

只需检查其中的代码即可.

它可以帮助您很多.

一切顺利
Hi,

Here ''m providing link for updating data through SqlDataAdapter

http://forums.asp.net/t/1222425.aspx/1

Just check code in it .

It can helps you alot.

All the best


这篇关于通过具有记录的数据适配器更新数据集中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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