问个问题,为什么添加一个datarow to datatable中,把以前datatable中记录全部复制一遍!!

seani 2002-11-13 02:58:04
如提
...全文
35 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
hikele 2002-12-02
  • 打赏
  • 举报
回复
因为原先的dataset中的值依然存在,同时有加了新的同样的值

查询前用:dataset1.clear()(vb.net用法)
c#的具体格式我不太清楚,不过你应当清楚的,呵呵
rbjojo 2002-11-13
  • 打赏
  • 举报
回复
DataRow drPrinter=dt.NewRow();
seani 2002-11-13
  • 打赏
  • 举报
回复
改了还是一样情况
seani 2002-11-13
  • 打赏
  • 举报
回复
噢,上面写错了,还是一样
aro 2002-11-13
  • 打赏
  • 举报
回复
DataRow drPrinter=dt.NewRow();
seani 2002-11-13
  • 打赏
  • 举报
回复
没人理?
seani 2002-11-13
  • 打赏
  • 举报
回复
漏了:dt.Rows.Add (drPrinter);
seani 2002-11-13
  • 打赏
  • 举报
回复
帖:
public static DataTable dt=this.getdata();//dt 获得数据库表数据.
DataRow drPrinter=new dt.NewRow();
drPrinter[0]=this.txtname.Text.trim();
drPrinter[1]=Decimal.ToInt32 ( this.numPrinter .Value );
drPrinter[2]=this.cboPorts .Text .Trim ();
drPrinter[3]=this.txt1.Text.Trim ();
drPrinter[4]=this.cboModel .Text .Trim ();
drPrinter[5]=this.GetHandShake ().Trim ();
drPrinter[6]=this.txtPageCode .Text .Trim ();
drPrinter[7]=this.cboName .Text .Trim ();
drPrinter[8]="ON";
aro 2002-11-13
  • 打赏
  • 举报
回复
你写的代码贴出来
seani 2002-11-13
  • 打赏
  • 举报
回复
上面那兄理解错了,我是说我想添加一条记录到datatable中,但是添加后平白无故多了几天,多的几条是原datatable的那几条数据,也就是重复了
yarshray 2002-11-13
  • 打赏
  • 举报
回复
private void CopyDataTable(DataTable myDataTable){
// Create an object variable for the copy.
DataTable copyDataTable;
copyDataTable = myDataTable.Copy();
// Insert code to work with the copy.
}

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧