为什么打印出来的都是乱码?能否直接打印出来?
using (SqlConnection con = new SqlConnection("server=.;database=bintest;uid=sa;pwd=")){
string sql = "select imageByte from picture";// imageByte 字段保存的是转换后 .doc 文档 的二进制数据(image 类型)
con.Open();
SqlCommand com = new SqlCommand(sql, con);
byte[] by = (byte[])com.ExecuteScalar();
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");
Response.ContentType = "application/ms-word";
Response.Charset = "gb2312";
Response.BinaryWrite(by); // 为什么打印出来的都是乱码?能否直接打印出来?
Response.End();
} --------------------编程问答-------------------- 这是输出到浏览器,和打印有什么关系?
charset不要设看看.
另外,你连接虽然用了using,但还是显式的关掉吧?
补充:.NET技术 , ASP.NET