Display the GIF image of the Access database with ASP

xiaoxiao2021-03-06  114

Write:

1: Read the GIF image file into the memory (a variable strTemp).

2: Write the database.

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")

'Really achieve OpenFile functions

rs.addnew

rs.fields ("image"). Appendchunk Bintmp

Rs.Update

Read and display:

Show.asp:

<%

DIM P

Diml

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; prorsist 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)

loop

%>

In HTML:

转载请注明原文地址:https://www.9cbs.com/read-99910.html

New Post(0)