C#多条件查出来的多个DataSet,然后循环将数据整合

               

        private List<string> barList;
        public List<string> BarList
        {
            get { return barList; }
            set { barList = value; }
        }

   DataSet dt = new DataSet();
      DataSet dt2 = null;
                foreach (string data  in  help.BarList )
                {
                    dt = DbOperatorStd.GetDataSet("select  xxx from xxx where xxx='" + data + "'");
                    if (dt2 == null)
                    {
                        dt2 = dt.Copy();
                    }
                    else
                    {
                        foreach (DataRow dtRow in dt.Tables[0].Rows)
                        {
                            DataRow m_nRow = null;
                            m_nRow = dt2.Tables[0].NewRow();
                            foreach (DataColumn dcCol in dt2.Tables[0].Columns)
                            {
                                m_nRow[dcCol.ColumnName] = dtRow[dcCol.ColumnName];
                            }
                            dt2.Tables[0].Rows.Add(m_nRow);
                        }
                    }
                }

posted @ 2019-04-24 08:58  江城苏幕遮溪沙  阅读(828)  评论(0编辑  收藏  举报