将行从一个数据集添加到另一个数据集 [英] adding rows from one dataset to another dataset

查看:106
本文介绍了将行从一个数据集添加到另一个数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据集说ds1和ds2,我想只添加一些选定的行(随机行)说ds1到ds2的第1行,第3行和第5行我怎么能这样做?

I have two datasets say ds1 and ds2, I want to add only some selected rows(random rows) say 1st row , 3rd rows and 5th row in ds1 to ds2 how can i do it??

推荐答案

试试这个链接

http://www.dirigodev.com/blog/web-development-execution/how-to-copy-rows-from-one-dataset-to-another / [ ^ ]



希望这有帮助
Try this link
http://www.dirigodev.com/blog/web-development-execution/how-to-copy-rows-from-one-dataset-to-another/[^]

Hope this helps


tablename.Columns.Add("columnName1");
tablename.Columns.Add("columnName2");
.
.
.
tablename.Columns.Add("columnNamen");

//note - should have same number of column and even column name that as the other table row to be copied or added

for (int intCount = 0; intCount < rowCount; intCount++)
            {
                string id = ds.Tables[0].Rows[intCount]["MUid"].ToString();


                ds1 = adm.getUserProfile(Convert.ToInt32(id));

                foreach (DataRow dr in ds1.Tables[0].Rows)
                {
                    ds2.Tables[0].Rows.Add(dr.ItemArray);
                }
                
            }


tablename.Columns.Add("columnName1");
tablename.Columns.Add("columnName2");
.
.
.
tablename.Columns.Add("columnNamen");

//note - should have same number of column and even column name that as the other table row to be copied or added

for (int intCount = 0; intCount < rowCount; intCount++)
            {
                string id = ds.Tables[0].Rows[intCount]["MUid"].ToString();


                ds1 = adm.getUserProfile(Convert.ToInt32(id));

                foreach (DataRow dr in ds1.Tables[0].Rows)
                {
                    ds2.Tables[0].Rows.Add(dr.ItemArray);
                }
                
            }


这篇关于将行从一个数据集添加到另一个数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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