雷利第一次出场视频:asp中如何读取SQL数据表内image数据类型的数据

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 11:16:09
SQL数据库中的A1表内的AA1字段数据类型为image,其内容数据为<Binary >

如何从库中读取这些<Binary>的二进制内容并输出,如果可以的话请写上源码实例。
内容非图片二进制,数据库为MSSQL,楼下提供的代码.actualsize这就开始出错,三楼的跟二楼的一样出错,Response对象错误'ASP0106:80020005 类型不匹配' 。另外这个段的长度是16

你可以用以下方法来实现
Response.ContentType = "image/*"
lngImageSize = adoRS.Fields("图片字段").ActualSize
Response.BinaryWrite adoRS.Fields("图片字段").GetChunk(lngImageSize)
-------------------------
只要是二进制格式的,用.GetChunk都是一样的,你可以读出来保存试试,还有就是之前你保存时也要以二进制形式保存。

将jinyusen的答案改一个地方,你看行不行.
Response.ContentType="text/html" ' .NET 书 上 是 用 这 个
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<%
Response.Expires = 0
Response.buffer=True
Response.clear
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=sqloledb;Server=(local);Database=picture;UID=sa;PWD=;"

Set Rs= Server.CreateObject("ADODB.RecordSet")
Sql="select img from pic where No=1000"
Rs.open sql,conn,1,1
Response.ContentType="text/html" ' .NET 书 上 是 用 这 个
Response.BinaryWrite Rs("big").GetChunk(750000)
Rs.close
conn.close
Set Rs=Nothing
Set conn=Nothing
%>

</head>
<body>

</body>
</html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<%
Response.Expires = 0
Response.buffer=True
Response.clear
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=sqloledb;Server=(local);Database=picture;UID=sa;PWD=;"

Set Rs= Server.CreateObject("ADODB.RecordSet")
Sql="select img from pic where No=1000"
Rs.open sql,conn,1,1
Response.ContentType="image/*"
Response.BinaryWrite Rs("big").GetChunk(750000)
Rs.close
conn.close
Set Rs=Nothing
Set conn=Nothing
%>

</head>
<body>

</body>
</html>

绝对高手,不过注意没有,您忘了说怎么样才能保存二进制数据了呵呵

参考学习