DataSet与Xml相互转化

string sql = "Select Top 10 F_ID,F_Name From T_Product";
            DataSet Ds 
= Database.ExecuteDataset(conn, CommandType.Text, sql);
            Ds.WriteXml(
"c:\\test.xml", XmlWriteMode.WriteSchema);//将数据输出到xml
            

            DataSet Ds2 
= new DataSet();
            Ds2.ReadXml(
"c:\\test.xml");//将xml加载到DataSet

            
this.GridView1.DataSource = Ds2.Tables[0].DefaultView;
            
this.GridView1.DataBind();
posted @ 2007-12-27 22:13  菩提树下的杨过  阅读(412)  评论(0编辑  收藏  举报