以集合中每一项作为查询条件,将查询到的所有数据形成一个表

        string sqlPid = "select medicine,name from pharmacyInfo where id= "+pharmacyid ;
            dt = db.getDataTable(sqlPid);
            medicine=dt.Rows[0][0].ToString();
            medicinelist = medicine.Split(',');
            DataTable dd = new DataTable();
     
            for (int i = 0; i < medicinelist.Length; i++)
            {  
                sqlStr = "select id,name,manufacturers,category,istop,new,indications=left(indications,27)+'...' from medicine  where name ='"+medicinelist[i]+"'";
                dd = db.getDataTable(sqlStr);
                if(i==0)
                ddss = dd.Clone();//克隆All的结构传递给dt
                DataRow[] der=dd.Select(); //通过条件得到符合条件的行
               for(int j=0;j<der.Length;j++) //将数组元素加入表...
               {
                  ddss.Rows.Add(der[j].ItemArray);  //出错提示为:该行已经属于另一个表 ddss.Rows.Add(der[i]);
                  int x=ddss.Rows.Count;//查看条数
               }

            }

posted @ 2011-09-08 09:19  渐入围城  阅读(305)  评论(0编辑  收藏  举报