当前位置:

Netease BBS 精华 >>讨论区精华 >>电脑技术 >>● ASP >>ASP典型范例

发信人: jackyz (Jj), 信区: ASP
标  题: 处理IMAGE类型的数据字段的方法
发信站: 网易虚拟社区 (Mon Mar  1 12:46:49 1999), 转信

以下的程序是我曾经用过的显示图形的ASP程序

**其中 PHOTO_IMG 字段的内容为Jpeg或Gif图象格式

希望有所帮助。
欢迎来信交流。

----------------------------------------
disp_photo.asp

<%@ LANGUAGE="VBSCRIPT" %>
<%'显示数据库中图象字段的内容

'过程 重定向结果图象
Private Sub redirect()
Response.Redirect "./images/NoPhoto.GIF"
end Sub

'过程 显示结果图象
Private Sub disp_photo()
dim P
dim L
L = 8192
'以8K为单位向 Client 端写数据
'设置文档类型
Response.ContentType = "image/JPEG"
'取得图象数据并显示
do
P = RS("PHOTO_IMG").GetChunk(L)
Response.BinaryWrite P
IF LenB(P) < L then exit do
loop
end Sub

'函数 从Request QueryString中返回查询参数
Private Function Req_arg(str)
dim tmp
tmp = ""
if Request.QueryString(str).Count <> 0 then
tmp = Request.QueryString(str)
end if
Req_arg = tmp
end Function

%>

<% '主程序 %>
<OBJECT RUNAT=Server ID=Conn PROGID="ADODB.Connection"></OBJECT>
<%
dim arg
dim SQL
arg = ""
arg = Req_arg("no")
if arg = "" then redirect()
'初始化数据库连接
Conn.Open session("dataconn_connectionstring")
SQL = "select * from photo_tab"
SQL = SQL & " where IMAGE_NO = " & arg

'取得查询结果
Set RS = Conn.Execute(SQL)
if (RS.BOF and RS.EOF) then
'没有找到图象数据
redirect()
else
'显示图象
disp_photo()
end if

'断开数据库连接
RS.Close
Conn.Close
%>

----------------------------------------

--
⊕◎JackyZ ㊣ Zspace◎⊕

※ 来源:.网易虚拟社区 http://club.netease.com.[FROM: 202.103.131.24]


当前位置:

Netease BBS 精华 >>讨论区精华 >>电脑技术 >>● ASP >>ASP典型范例
 
(C)1997-1998 版权所有
广州网易计算机系统有限公司