使用dataadapter,dataset在数据库表中添加一行 [英] add a row in database table using dataadapter, dataset
本文介绍了使用dataadapter,dataset在数据库表中添加一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DataSet ds= new DataSet();
DataTable dt2 = new DataTable();
System.Data.SqlClient.SqlCommandBuilder cb;
cb = new System.Data.SqlClient.SqlCommandBuilder(tableView);
DataRow dRow = dset.Tables["Info"].NewRow();
dRow[0] = txt_Fname.Text;
dRow[1] = txt_Lname.Text;
dRow[2] = txt_Address.Text;
dRow[3] = Date_picker.Text;
dset.Tables["Info"].Rows.Add(dRow);
tableView.Update(dset, "Info");
tableView.UpdateCommand = cb.GetUpdateCommand();
tableView.Fill(dt2);
tableView.AcceptChangesDuringUpdate = true;
该值位于数据集中,即使在进行更新后也不会在table.update中更新.
我正在使用速成版.谁能帮忙解决这个问题
谢谢.
the value is in dataset it is not getting updated in table.even after giving update.
I am using express edition. can any one help in solving this
thanks,.
推荐答案
来自以下问题的陈述
From the following statements of the question
tableView.Update(dset, "Info");
tableView.UpdateCommand = cb.GetUpdateCommand();
可以看出,在调用Update
方法之后分配了UpdateCommand
.
只需检查是否由于这个原因有任何问题.
It can be seen that UpdateCommand
is assigned after calling the Update
method.
Just check whether there is any problem due to this.
您能否看一下下面给出的此链接:
http://msdn.microsoft.com/en-us/library/33y2221y (v = vs.100).aspx [
Can you please have a look at this link given below:
http://msdn.microsoft.com/en-us/library/33y2221y(v=vs.100).aspx[^]
这篇关于使用dataadapter,dataset在数据库表中添加一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文