怎样处理附件的打开
1string strCnn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
2SqlConnection myConnection = new SqlConnection(strCnn);
3SqlCommand command = new SqlCommand("select 附件, 附件名称, 附件类型 from 表名 Where NewsID =" + Request.QueryString["id"], myConnection);
4myConnection.Open();
5SqlDataReader dr = command.ExecuteReader();
6if (dr.Read())
7{
8 Response.Clear();
9
10 Response.HeaderEncoding = System.Text.Encoding.GetEncoding("GB2312");
11
12 Response.AddHeader("Content-Type", dr["附件类型"].ToString()); // File Upload时存到数据库的
13
14 Response.AppendHeader("TITLE", dr["附件名称"].ToString());
15
16 Response.AppendHeader("Content-Disposition", "inline;filename=\"" + dr["附件名称"].ToString() + "\"");
17
18 Response.BinaryWrite((byte[])dr["附件"]);
19}
20dr.Close();
21myConnection.Dispose();
22
2SqlConnection myConnection = new SqlConnection(strCnn);
3SqlCommand command = new SqlCommand("select 附件, 附件名称, 附件类型 from 表名 Where NewsID =" + Request.QueryString["id"], myConnection);
4myConnection.Open();
5SqlDataReader dr = command.ExecuteReader();
6if (dr.Read())
7{
8 Response.Clear();
9
10 Response.HeaderEncoding = System.Text.Encoding.GetEncoding("GB2312");
11
12 Response.AddHeader("Content-Type", dr["附件类型"].ToString()); // File Upload时存到数据库的
13
14 Response.AppendHeader("TITLE", dr["附件名称"].ToString());
15
16 Response.AppendHeader("Content-Disposition", "inline;filename=\"" + dr["附件名称"].ToString() + "\"");
17
18 Response.BinaryWrite((byte[])dr["附件"]);
19}
20dr.Close();
21myConnection.Dispose();
22
继续追寻。。。。。。