如何将 SQL Server数据库中Image字段的图象 显示在网页上。(50分)

  • 主题发起人 apolloone
  • 开始时间
A

apolloone

Unregistered / Unconfirmed
GUEST, unregistred user!
我想将 SQL Server数据库中类型为Image的图象 显示在网页上。
我这样编写代码的,但行不通,请各位帮帮忙:[:)]

<input type="image" border="0" name="imageField" src="<%=(Recordset1.Fields.Item("photo").Value)%>">
 
写到一个iis临时目录中比如 /temp/temp.jpg。然后这样用:
<img src ="/temp/temp.jpg">
 
'showimg.asp
<!--#include file="Connections/txl.asp" -->
<%
Set Conn=Server.CreateObject("Adodb.Connection")
Conn.Open MM_txl_STRING
SQL="Select * From photo Where NICHENG='"&amp;Request("id")&amp;"' and type='G'"
Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.Open SQL,Conn,1,1
Response.ContentType = "image/*"

Response.BinaryWrite rs("photo").getChunk(7500000)
Rs.Close
Conn.Close
%>
其他文件调用
<img src="showimg.asp?id=<%=session("nicheng")%>" alt="形象照,酷吧!">
 
iapollo兄弟:

我这样做了怎么还不行:请帮我看一下程序:
//showimg.asp 我的数据表名为 ware 、其中字段image为图象字段
<!--#include file="Connections/hwsm.asp" -->
<%
Set Conn=Server.CreateObject("Adodb.Connection")
Conn.Open MM_txl_STRING
SQL="Select * From ware Where code='"&amp;Request("id")&amp;"'"
Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.Open SQL,Conn,1,1
Response.ContentType = "image/*"

Response.BinaryWrite rs("image").getChunk(7500000)
Rs.Close
Conn.Close
%>
//下面是在一页里显示五行记录(包括图象)的程序
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/hwsm.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_hwsm_STRING
Recordset1.Source = "SELECT code, name, unit, price, image FROM dbo.ware"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = 6
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="75%" border="1">
<tr>
<td width="26%">&amp;nbsp;</td>
<td width="25%">&amp;nbsp;</td>
<td width="41%">&amp;nbsp;</td>
<td width="4%">&amp;nbsp;</td>
<td width="4%">&amp;nbsp;</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td width="26%"><%=(Recordset1.Fields.Item("code").Value)%> </td>
<td width="25%"><%=(Recordset1.Fields.Item("name").Value)%> </td>
<td width="41%"><%=(Recordset1.Fields.Item("unit").Value)%> </td>
<td width="4%"><%=(Recordset1.Fields.Item("price").Value)%></td>
<td width="4%">
<img src="showimg.asp?id=<%=(Recordset1.Fields.Item("code").Value)%>" alt="&amp;ETH;&amp;Icirc;&amp;Iuml;ó&amp;Otilde;&amp;Otilde;,&amp;iquest;á°&amp;Eacute;!">
</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
</form>
</body>
</html>
<%
Recordset1.Close()
%>


怎么没有办法显示图象呢?

请帮我看看,好吗?先谢谢了!
 
哦!
可以了,太高兴了!

Conn.Open MM_txl_STRING忘了改为“Conn.Open MM_hwsm_STRING”

谢谢iapollo
 
接受答案了.
 
顶部