本帖最后由 twp104twp 于 2009-09-21 08:36:26 编辑

解决方案 »

  1.   

    急!关于利用c# 读取sql2000数据库的数据为xml格式的文件
      

  2.   

    应该利用DATASET.WRITEXML方法,图片看不到
      

  3.   

     
    SQL77
     
    (77C#+SQL) 我用的就是你说的那样,dataset.writexml但是不是给的图片的那种效果我把我的源代码发来看看 string sqlstr = " select data,discountno,discountname,productno,productname,quantity,price,pihao,unit,type ,accountno,accountname  from tslmsyy for xml Auto   ";       //Query(sqlstr);
           //string yiyao = "XMLFile.xml";
           SqlDataAdapter sda = new SqlDataAdapter(sqlstr, mydb.getcon());
           DataSet ds = new DataSet();
           sda.Fill(ds, "dstable");
           //ds.ReadXml(Server.MapPath("./") + "XMLFile.xml");  //+ "/web.config");
           string filepath = Server.MapPath("./xml/A.xml");
           ds.WriteXml(filepath);       DataTable tb = new DataTable();
           DataView dv = new DataView();
           tb = ds.Tables["dstable"];
           dv = new DataView(tb);
           this.GridViewyy.DataSource = dv;
           //this .GridViewyy .DataBind ();
           gridviewread();
             Response.Write("<script language='javascript'>alert('你已经成功生成了xml文件!')</script>");但是生成的xml格式文件的内容是如下的样子
    <?xml version="1.0" standalone="yes"?>
    <NewDataSet>
      <dstable>
        <XML_F52E2B61-18A1-11d1-B105-00805F49916B>&lt;tslmsyy data="2009-07-07T00:00:00" discountno="p500108015x15ca" discountname=" 重庆九州通医药有限公司" productno="ccg039001g" productname="消渴丸" quantity="2" price="16" pihao="m01018" unit="瓶" type="批发" accountno="pdd3" accountname="重庆医药销售有限公司"/&gt;&lt;tslmsyy data="2007-01-02T00:00:00" discountno="ppp520" discountname="重庆" productno="9001g" productname="渴丸" quantity="3" price="21" pihao="018" unit="瓶" type="批发" accountno="d3" accountname="重庆医药"/&gt;</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
      </dstable>
    </NewDataSet>