如何查看SQL Server中image中是否有图片

wyjun1985 2009-08-16 04:40:54
数据库文件时从别处拷来的,其中有一个表内有image字段,用来存储图片,我将它显示在网页上,出来的是红XX,不知道是我的代码有问题还是里面根本就没存图片。那个数据库文件有17M,我想应该是存了吧!
下面是我的代码:
show.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="image/*; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%
set conn=server.CreateObject("adodb.connection")
conn.connectionstring="driver={sql server};server=KIMI;uid=sa;pwd=sa;database=steel_wsf;"
conn.open
set rs = server.CreateObject("adodb.recordset")
sql = "select * from pokou"
rs.open sql,conn,1,1
do until rs.eof
response.Write(rs("id"))
%>
<img src="load.asp?id=<%=rs("id")%>"/>
<%
rs.movenext
loop
rs.close
conn.close
set rs = nothing
set conn = nothing
%>
</body>
</html>

load.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%
response.Expires=0
response.Buffer=true
response.Clear()
set conn=server.CreateObject("adodb.connection")
conn.connectionstring="driver={sql server};server=KIMI;uid=sa;pwd=sa;database=steel_wsf;"
conn.open
Response.ContentType="image/*"
set rs1 = server.CreateObject("adodb.recordset")
sql="select * from pokou where id="&request.QueryString("id")
rs1.open sql,conn,1,1
response.BinaryWrite rs1("pkt1").getchunk(7500000)
rs1.close
conn.close
set rs1=nothing
set conn=nothing
%>
</body>
</html>
...全文
87 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lbcleo 2009-08-17
[Quote=引用 3 楼 wcwtitxu 的回复:]
load.asp 不要加那些 html, head, body 什么的
VBScript code<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><%Dim conn, rs1, id
id= Request.QueryString("id")IfNotIsNumeric(id)Then Response.End

response.Expires=0
response.Buffer=trueset conn= server.CreateObject("adodb.connection")
conn.connectionstring="driver={sql server};server=KIMI;uid=sa;pwd=sa;database=steel_wsf;"
conn.open
Response.ContentType="image/*"set rs1= server.CreateObject("adodb.recordset")
sql="select pkt1 from pokou where id="& id
rs1.open sql,conn,1,1
response.BinaryWrite rs1("pkt1").getchunk(7500000)
rs1.close
conn.closeset rs1=nothingset conn=nothing
%>
[/Quote]
up
回复
wcwtitxu 2009-08-16
load.asp 不要加那些 html, head, body 什么的

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim conn, rs1, id
id = Request.QueryString("id")
If Not IsNumeric(id) Then Response.End

response.Expires=0
response.Buffer=true
set conn = server.CreateObject("adodb.connection")
conn.connectionstring="driver={sql server};server=KIMI;uid=sa;pwd=sa;database=steel_wsf;"
conn.open
Response.ContentType="image/*"
set rs1 = server.CreateObject("adodb.recordset")
sql="select pkt1 from pokou where id=" & id
rs1.open sql,conn,1,1
response.BinaryWrite rs1("pkt1").getchunk(7500000)
rs1.close
conn.close
set rs1=nothing
set conn=nothing
%>
回复
ambitionzfx 2009-08-16
sql="select * from pokou where id="&request.QueryString("id")
看看 数据库字段的名称是什么类型 不是int float等数字型的话 改成
sql="select * from pokou where id='"&request.QueryString("id")&"'"试试
回复
liuwei_IT_love 2009-08-16
<img src="load.asp?id=<%=rs("id")%>"/>,src="这个地方不应该是字段名称吗?"
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告