WEB开发网
开发学院数据库Access 用ASP显示ACCESS数据库的的GIF图象 阅读

用ASP显示ACCESS数据库的的GIF图象

 2008-10-07 00:00:00 来源:WEB开发网   
核心提示:写入:1:把gif图像文件读入内存(一个变量strTemp),2:写入数据库,用ASP显示ACCESS数据库的的GIF图象,Dim binTmp() As ByteDim conn As ADODB.ConnectionDim rs As ADODB.RecordsetDim strSql As StringSet c

写入:

1:把gif图像文件读入内存(一个变量strTemp)。

2:写入数据库。

 Dim binTmp() As Byte
 Dim conn As ADODB.Connection
 Dim rs As ADODB.Recordset
 Dim strSql As String
 Set conn = New ADODB.Connection
 Set rs = New ADODB.Recordset
 conn.Open "db"
 strSql = "select * from tbImage"
 rs.Open strSql, conn, 1, 3
 OpenFile ("bayshore.jpg")
 '请自己实现OpenFile函数
 rs.AddNew
 rs.Fields("image").AppendChunk binTmp
 rs.Update

读出和显示:

 show.asp:
 <%
 dim P
 dim L
 L = 8192
 dim conn,rs,strSql
 set conn=server.CreateObject("ADODB.Connection")
 conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &server.MapPath(".") & "db2.mdb;Persist Security Info=False"
 set rs=server.CreateObject("ADODB.Recordset")
 strSql = "select * from tbImage"
 Response.ContentType = "image/gif"
 'Important!
 rs.open strSql,conn,1,1
 rs.movelast
 do
 P = rs("image").GetChunk(L)
 Response.BinaryWrite P
 IF LenB(P) < L then exit do
 loop
  %>

在html中:

<image src=show.asp>

Tags:ASP 显示 ACCESS

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接