當前位置:開發者網絡 >> 技術教程 >> 數據庫專欄 >> MSAccess >> 內容
精彩推薦
分類最新教程
分類熱點教程
    
用ASP顯示ACCESS數據庫的的GIF圖像
作者:未知
日期:2005-04-29
人氣:
投稿:(轉貼)
來源:未知
字體:
收藏:加入瀏覽器收藏
以下正文:
寫入:
   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>
相關文章: