发信人: jackyz() 
整理人: i_am_trueman(2003-10-24 10:18:40), 站内信件
 | 
 
 
以下的程序是我曾经用过的显示图形的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://www.moon-soft.com.[FROM: 202.103.131.24]
  | 
 
 
 |