连接两个datatable 急! 我有两个datatable table1,table2, 他们两个的column都相同,我想用c#代码 把table2的内容接到table1后面应该怎么写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 datetable好像有个合并的函数吧,Merge? DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("客户A", typeof(string)); dt.Rows.Add(1, "A1"); dt.Rows.Add(2, "A2"); dt.Rows.Add(3, "A3"); dt.PrimaryKey = new DataColumn[] { dt.Columns["id"] }; DataTable dt2 = new DataTable(); dt2.Columns.Add("ID", typeof(int)); dt2.Columns.Add("客户B", typeof(string)); dt2.Rows.Add(1, "B1"); dt2.Rows.Add(2, "B2"); dt2.Rows.Add(4, "B4"); dt2.PrimaryKey = new DataColumn[] { dt2.Columns["id"] }; dt.Merge(dt2); this.DataGrid1.DataSource = dt.DefaultView; this.DataGrid1.DataBind(); 我只知道用SQl语句Select * from table1的数据库的表 Union Select * from table2的数据库的表然后查询得到的结果就是 table2的内容接到table1后面 如果两个表格Column一样。table1.Merge(table2) 网站首页设计布局 我想获得页面中所有TextBox的值用js获得 论坛消息提示一般用什么现实。帮忙,急 关于验证与邀请码的问题 发送邮件失败 关于网站静态化的一点疑问 关于日期的简单sql语句 ascx文件中控件要引用javascript验证,是把标签放在本文件中,还是放在aspx文件中? 又一个关于ASP.net/IIS(权限)配置问题 (很急!) 有无西安ASP.NET致强者?HELP ME!!! 新人初次用asp.net+sql2005,请指点需看那些方面的书 请问哪儿有好的网上购物商店源码
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("客户A", typeof(string)); dt.Rows.Add(1, "A1");
dt.Rows.Add(2, "A2");
dt.Rows.Add(3, "A3");
dt.PrimaryKey = new DataColumn[] { dt.Columns["id"] }; DataTable dt2 = new DataTable();
dt2.Columns.Add("ID", typeof(int));
dt2.Columns.Add("客户B", typeof(string)); dt2.Rows.Add(1, "B1");
dt2.Rows.Add(2, "B2");
dt2.Rows.Add(4, "B4");
dt2.PrimaryKey = new DataColumn[] { dt2.Columns["id"] };
dt.Merge(dt2); this.DataGrid1.DataSource = dt.DefaultView;
this.DataGrid1.DataBind();
Select * from table1的数据库的表 Union Select * from table2的数据库的表然后查询得到的结果就是 table2的内容接到table1后面
table1.Merge(table2)