获取一条记录的数据并生成XML文档
1![](/Images/OutliningIndicators/None.gif)
2
//获取一条记录的数据并生成XML文档
3
private void ExportOne(string KeyID)
4
{
5
string strSQL = "Select * From PO Where HmNumPO='" + KeyID + "'";
6![](/Images/OutliningIndicators/InBlock.gif)
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![](/Images/OutliningIndicators/InBlock.gif)
10
connection.Open();
11
SqlDataReader rdr = cmd.ExecuteReader();
12
rdr.Read();
13![](/Images/OutliningIndicators/InBlock.gif)
14
Response.Clear();
15
Response.Buffer = true;
16
Response.ContentType = "text/xml";
17
Response.Charset = "utf-8";
18![](/Images/OutliningIndicators/InBlock.gif)
19![](/Images/OutliningIndicators/InBlock.gif)
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![](/Images/OutliningIndicators/InBlock.gif)
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![](/Images/OutliningIndicators/InBlock.gif)
50
Response.Write("</Content>");
51
Response.Write("</Root>");
52![](/Images/OutliningIndicators/InBlock.gif)
53![](/Images/OutliningIndicators/InBlock.gif)
54
Response.Flush();
55
Response.End();
56
57
}
58![](/Images/OutliningIndicators/None.gif)
59![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/InBlock.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
58
![](/Images/OutliningIndicators/None.gif)
59
![](/Images/OutliningIndicators/None.gif)