从数据库中读取image字段内容的一个问题!
在数据库表中的image字段中,存了图片以及PDF
现在要在浏览器中显示字段的内容,代码如下:
<%
string sql="select personimage,personimagetype from person where personid=1"
sqlconnection connection=new sqlconnection("server=(local);database=test;uid=gqy;pwd=gqy")
sqlcommand command=new sqlcommand(sql,connection)
connection.open()
sqldatareader dr=command.executereader()
if(dr.read())
{
response.contenttype=dr["personimagetype"].tostring()
response.binarywrite((byte[]) dr["personimage"])
}
connection.close()
%>
现在的问题是:浏览图片的时候没什么问题,但是浏览PDF的时候不能像浏览图片一样直接显示,而是会弹出一对话框,让选择是打开还是保存,选择打开后,自动启动PDF阅读器打开PDF文档。我希望实现这样的目标:当浏览PDF的时候,能直接在IE里显示PDF文档(像现在网上很多是这样的)!
谢谢!