合并两个结构一样的dataset数据集

来源:互联网 发布:淘宝图片怎么加链接 编辑:程序博客网 时间:2024/05/16 05:43

DataSet DS1=........;
DataSet DS2=........;
//以上两个DS的表结构是一样的如


DS1的数据是
name/password
王强/123
张三/321


DS2的数据是
name/password
李四/555
狗蛋/666

结果DS1=DS1+DS2

方法一:
ds1.Tables[0].Merge(ds2.Tables[0]);
方法二:
                    if (ds2.Tables[0].Rows.Count > 0)
                    {

                        foreach (DataRow dr in ds2.Tables[0].Rows)
                        {

                            ds1.Tables[0].ImportRow(dr);

                        }
                    }