请问高手如何用ASP读取sql server的 Text类型的文件出来?(

于之 2006-05-18 08:59:43
我现在有一个Sql server表 book, 其中有两个字段,一个是 title(书名), filename(文件)Text字段,现在,我已经将一些图片或文件已经上传至这个表的 filename字段中保存了, 现在我的问题是如何通过ASP将那个字段中的文件读取出来或显示出来
exec="select * from book"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>
<table style="table-layout:fixed" bordercolordark=#88ddff bordercolorlight=white bgcolor=white width='100%' border="0" cellspacing="0" cellpadding="0">
<%do while not rs.eof%>
<tr height="18">
<%
ntitle=trim(rs("title"))
nfiles=rs("files")
Response.write rs("files")

%>
<td width='72%' valign='top' onmouseover="this.style.backgroundColor='#FFCCFF'; " onmouseout="this.style.backgroundColor='#FFFFFF'" style="LEFT: 0px; WORD-WRAP: break-word" align=left><a href=viewnewtj.asp?id=<%=rs("id")%> target='_blank'><img src='/images/jt1.gif' border='0'> <font color=#000000><%=ntitle%>    <a href='<%=ntitle%>'><%=nfiles%></a></font></td>
</tr>
<%
rs.movenext
loop
set rs=nothing
conn.close
set conn=nothing
%>
</table>

我这样读取都不行

是要读取那个Text类型字段中保存的文件出来,请高手指点,万分谢谢!

...全文
242 10 打赏 收藏 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
dh20156 2006-05-29
  • 打赏
  • 举报
回复
参考一下这种方式吧:
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("ADODB.recordset")
strsql="Select top 1 [img] From [icon] Where id="&trim(request("id"))
rs.open strsql,conn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite rs("img").getChunk(7500000)
rs.close
set rs=nothing
set conn=nothing
%>
lingfeng7885 2006-05-29
  • 打赏
  • 举报
回复
你应该是读取出来,不显示图片吧!

你用这样的方式读取肯定不行!
于之 2006-05-29
  • 打赏
  • 举报
回复
高手帮帮啊!!!!怎么卡了两个星期了,还是没有搞定
于之 2006-05-21
  • 打赏
  • 举报
回复
存的是文件! 不是路径
taochunsong 2006-05-21
  • 打赏
  • 举报
回复
你在数据库中是存的文件,还是文件的路径阿?
于之 2006-05-21
  • 打赏
  • 举报
回复
exec="select * from filemanage"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>
<table style="table-layout:fixed" bordercolordark=#88ddff bordercolorlight=white bgcolor=white width='100%' border="0" cellspacing="0" cellpadding="0">
<%do while not rs.eof%>
<tr height="18">
<%
ntitle=trim(rs("title"))
%>
<td width='72%' valign='top' onmouseover="this.style.backgroundColor='#FFCCFF'; " onmouseout="this.style.backgroundColor='#FFFFFF'" style="LEFT: 0px; WORD-WRAP: break-word" align=left><a href=viewnewtj.asp?id=<%=rs("id")%> target='_blank'><img src='/images/jt1.gif' border='0'> <font color=#000000><%=ntitle%>    <a href='<%=ntitle%>'><%=Response.BinaryWrite(rs("files"))%></a></font></td>
</tr>
<%
rs.movenext
loop
set rs=nothing
conn.close
set conn=nothing
%>
</table>


改成了这样,为何提示如下错误呢?
技术信息(用于支持人员)

错误类型:
Active Server Pages, ASP 0113 (0x80004005)
超过了脚本运行的最长时间。可以为 Server.ScriptTimeOut 属性指定新值或更改 IIS 管理工具中的相应值来更改此限制。
/filegl/cxfiles.asp


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

网页:
GET /aaa/cxfiles.asp

时间:
2005年5月21日, 上午 11:27:21
dgrwang 2006-05-18
  • 打赏
  • 举报
回复
你把图片什么都存成2进制了,还想能直接读出来?还是fso
gsyst520 2006-05-18
  • 打赏
  • 举报
回复
filename(文件)Text字段
nfiles=rs("files")
????
gameboy766 2006-05-18
  • 打赏
  • 举报
回复
二进制数据需要用Response.BinaryWrite输出,如Response.BinaryWrite(rs("files")),但需要注意的是,在同一次响应中,Response.BinaryWrite和Response.Write是不能同时存在的,也就是说这次响应的输出要么是Html(文本)的,要么是二进制的,因此显示图片需要单独一个页面处理,然后在你的显示页面当做图片调用,如以楼主上面为例,在显示页面通过<img src="image.asp?id=相关图片ID">调用图片,然后在image.asp通过id查询相应数据然后用Response.BinaryWrite(rs("files"))输出。
是是非非 2006-05-18
  • 打赏
  • 举报
回复
用FSO

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧