需要帮助来合并两个数据集 [英] need help to merge two datasets

查看:69
本文介绍了需要帮助来合并两个数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友...!

我有两个数据集,它们完全相同,只有一个字段在第一个数据集中的值为零,在第二个数据集中的值为1.

假设ds1包含col1,它们的所有值均为0和
ds2包含具有所有值1的列,而其他列相同

现在,我想创建第三个数据集,其中分别具有值1和0的行交替出现,例如


1
0
1
0
...

有谁知道解决方案吗?

Hi friends...!

I have two datasets which are identical with only one field having a value zero in first dataset and 1 in second dataset.

say ds1 contains col1 which have all values 0 and
ds2 contains column which have all values 1 with other columns same

now i want to create a 3rd dataset in which rows hving values 1 and 0 appear alternately such as


1
0
1
0
...

does anyone know a solution?

推荐答案

DS1.Merge(DS2);
DS1.AcceptChanges();
DS1.Merge(DS2);
DS1.AcceptChanges();




您是指ado.net数据集吗?如果是这样,我假设您的数据集中有一个具有相同列定义的数据表.是否要将所有数据合并到一张表中?

数据表没有固有的顺序,它们是行的集合,
尽管这些行通常按照它们添加到数据表的顺序排列.您可以通过以正确的顺序一次添加2个表中的每一行来确保合并表中的特定顺序.

如果要以某种控件(Web,winforms?)显示数据,则控件将有某种方式对显示的行进行排序,通常是通过控件的数据源.

我希望这是有用的.祝你好运
Hi,

Are you referring to a ado.net dataset? If so I assume you have a datatable in the datasets with identical column definitions. Do you want to merge the tables into 1 table with all the data?

Datatables have no inherent order, they are collections of rows,
although the rows usually are in the order they are added to the datatable. You could ensure a particualar order in the merged table by adding each row from the 2 tables one at a time in the correct order.

If you are displaying the data in some sort of control (web, winforms?) then the control would have some way of ordering the rows displayed, usually thru the controls datasource.

I hope this is useful. Good Luck


这篇关于需要帮助来合并两个数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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