欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-04-09 08:59:43
private List barList; public List BarList { get { return barList; } set { barList = value; } } DataSet dt = new DataSet(); DataSet dt2 ......

               

        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);
                        }
                    }
                }