从数据库中将以image类型存入的word文件读出,在ie中用word显示,但是没有数据,只有一个word框架(难道一定要用一个filestream先将读出的内容放到一个文件中吗)public void LoadBinary()
{
SqlCommand cmd=new SqlCommand();
cmd.CommandText="select image from temp where ename='ReportDoc'";
cmd.Connection=conn;
conn.Open();
SqlDataReader binaryReader=cmd.ExecuteReader();
while(binaryReader.Read())
{
Response.ContentType="Application/msword";
Response.BinaryWrite((byte[])binaryReader["image"]);
}
binaryReader.Close();
conn.Close();
}请各位大虾帮忙看看
{
SqlCommand cmd=new SqlCommand();
cmd.CommandText="select image from temp where ename='ReportDoc'";
cmd.Connection=conn;
conn.Open();
SqlDataReader binaryReader=cmd.ExecuteReader();
while(binaryReader.Read())
{
Response.ContentType="Application/msword";
Response.BinaryWrite((byte[])binaryReader["image"]);
}
binaryReader.Close();
conn.Close();
}请各位大虾帮忙看看
{
SqlCommand cmd=new SqlCommand();
cmd.CommandText="select image from temp where ename='ReportDoc'";
cmd.Connection=conn;
conn.Open();
SqlDataReader binaryReader=cmd.ExecuteReader();
binaryReader.Read()
Dim Buffer() As Byte
Buffer=binaryReader("列名")
conn.Close(); Response.ContentType = "Application/octet-stream";
Response.Clear();
Response.AddHeader("Content-Disposition", " filename=");
Response.BinaryWrite(Buffer);
Response.End();
}
Response.ContentType = "Application/octet-stream";
Response.Clear(); //文件名包括你的文件的后缀(.doc)
Response.AddHeader("Content-Disposition", " filename= a.doc");
Response.BinaryWrite(btImage);
Response.End();
{
SqlCommand cmd=new SqlCommand();
cmd.CommandText="select image from temp where ename='HelpDoc'";
cmd.Connection=conn;
conn.Open();
SqlDataReader binaryReader=cmd.ExecuteReader();
binaryReader.Read();
byte[] buffer=(byte[])binaryReader["image"];
binaryReader.Close();
conn.Close();
Response.ContentType = "Application/octet-stream";
Response.Clear();
Response.AddHeader("Content-Disposition", "filename=ttt.doc");
Response.BinaryWrite(buffer);
Response.End();
修改后的,执行了一遍,依然没有显示数据
}
byte[] btImage = (byte[])o;
Response.ContentType = "Application/octet-stream";
Response.Clear(); //文件名包括你的文件的后缀(.doc)
Response.AddHeader("Content-Disposition", " filename= a.doc");
Response.BinaryWrite(btImage);
Response.End();
***********************************所用的代码是没问题。你要解决的问题是:1:显示Word页面应为空白页面,即无任何控件。
2:
建议在客户机试运行看看效果?
在客户端确实可以显示数据