用StreamWriter如何把数据库里的想要的内容生成一个文本文件?请给个代码,谢谢各位!

解决方案 »

  1.   

    是要什么格式的文本文件?比如xml,是可以实现的。
      

  2.   

    这个也行,TXT的也行,能实现就可以,给个代码,谢谢了!
      

  3.   

    用 DataSet来存入数据库~~~~~~
    DataSet ds = new DataSet();
    ds.ReadXml(Server.MapPath("myXml.xml"));
    //Show in the DataGrid1
    DataGrid1.DataSource = ds.Tables[0].DefaultView; //Modify a Row
    ds.Tables[0].Rows[0]["Bianhao"] = "520wangfei";
    ds.Tables[0].Rows[0]["Name"] = "CrazyDream";
    ds.Tables[0].Rows[0]["LoginPass"] = "pacal1983";
    ds.Tables[0].Rows[0]["AdvPass"] = "pacal19831011";
    ds.Tables[0].Rows[0]["StoreName"] = "WorldStore";
    //Add a new row to the table
    DataTable dt = new DataTable();
    DataRow dr; ds.WriteXml(Server.MapPath("myXml.xml"));
      

  4.   

    System.IO.FileStream myFileStream = new System.IO.FileStream
           (Server.MapPath("myXmlDoc.txt"), System.IO.FileMode.Create);
    System.Xml.XmlTextWriter myXmlWriter = 
           new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
    thisDataSet.WriteXml(myXmlWriter);   
    myXmlWriter.Close();