• 获取一条记录的数据并生成XML文档


     1
     2    //获取一条记录的数据并生成XML文档
     3    private void ExportOne(string KeyID)
     4    {
     5        string strSQL = "Select * From PO Where HmNumPO='" + KeyID + "'";
     6
     7        SqlConnection connection = new SqlConnection("Data Source=(local);Initial Catalog=CSS;Persist Security Info=True;User ID=sa;Password=123456");
     8        SqlCommand cmd = new SqlCommand(strSQL, connection);
     9
    10        connection.Open();
    11        SqlDataReader rdr = cmd.ExecuteReader();
    12        rdr.Read();
    13
    14        Response.Clear();
    15        Response.Buffer = true;
    16        Response.ContentType = "text/xml";
    17        Response.Charset = "utf-8";
    18
    19
    20        Response.AppendHeader("Content-Disposition""attachment;filename=" + rdr["HmNumPO"].ToString() + ".xml");
    21        // 如果设置为 GetEncoding("GB2312");导出的文件将会出现乱码!!!
    22        Response.ContentEncoding = System.Text.Encoding.UTF8;
    23        //Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
    24        //DBNull tmpDBNull = new DBNull();
    25        
    26
    27        Response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
    28        Response.Write("<Root>");
    29        Response.Write("<Title></Title>");
    30        Response.Write("<Content>");
    31        Response.Write("<Section4>");
    32        Response.Write("    <Date>" + rdr["HmNumPO"].ToString() + "</Date>");
    33        Response.Write("</Section4>");
    34        Response.Write("<Section6>");
    35        Response.Write("    <SupplierName>" + rdr["CostcoPONum"].ToString()  + "</SupplierName>");
    36        Response.Write("    <QuoteProvidedBy>" + rdr["SHCity"].ToString() + " Liu</QuoteProvidedBy>");
    37        Response.Write("    <Position>" + rdr["SHZip"].ToString() + "</Position>");
    38        Response.Write("</Section6>");
    39        Response.Write("<Section7>");
    40        Response.Write("   <Phone>" + rdr["SHPhone"].ToString() + "</Phone>");
    41        Response.Write("    <Email>" + rdr["SHEmail"].ToString() + "</Email>");
    42        Response.Write("</Section7>");
    43        Response.Write("<Section9>");
    44        Response.Write("    <Description>" + rdr["CostcoPONum"].ToString() + "</Description>");
    45        Response.Write("</Section9>");
    46        Response.Write("<Section10>");
    47        Response.Write("    <Description>" + rdr["CostcoPONum"].ToString() + "</Description>");
    48        Response.Write("</Section10>");
    49
    50        Response.Write("</Content>");
    51        Response.Write("</Root>");
    52
    53
    54        Response.Flush();
    55        Response.End();        
    56    
    57    }

    58
    59
  • 相关阅读:
    dalvik浅析二:jni、so
    android apk壳
    prism4 StockTrader RI 项目分析一些体会
    PRISM ‘VS100COMNTOOLS’ not set. Cannot set the build environment
    安卓移动应用代码安全加固系统设计及实现
    手机游戏外挂技术研究与运用
    移动终端安全威胁与应对措施
    游戏软件反外挂技术方案的设计和安全解决方案
    网络安全等级保护 2.0 下的安全体系建设
    APP加密,ios代码混淆工具,虚拟化技术 适用于移动应用程序的虚拟化加密软件
  • 原文地址:https://www.cnblogs.com/liuweitoo/p/914825.html
Copyright © 2020-2023  润新知