mguedes
asked on
Images & Access97 & Web pages...
Anyone know how to display an Access db OLE field(with a image)in a web page(ASP)....
thank´s in advance
MG
thank´s in advance
MG
ASKER
I know how to make this with the SQL server.....but now i want make the same with ACCESS......
Since I have never try this before, just guessing...
This has nothing to do with Response.BinaryWrite method?
'get the data here....
set rs = con.execute("SELECT thumbnail FROM rec WHERE recID =...')
response.contenttype = "images/gif"
response.binarywrite rs("thumbnail")
This has nothing to do with Response.BinaryWrite method?
'get the data here....
set rs = con.execute("SELECT thumbnail FROM rec WHERE recID =...')
response.contenttype = "images/gif"
response.binarywrite rs("thumbnail")
ASKER
the problem was that the ole field does not have just binary data....it contain an header description(i guess)
MasseyM was right there is almost no way to do this. In order to do it you are going to have to process what is stored in the database and strip out all the OLE headers and other information. Then use the binarywrite method. Sorry I don't know how to do it, but that is what needs to be done for this to work.
It can be done allright, I am doing it all the time. It depends very much on how you put the image into Access. If you insert the image into Access using the normal OLE-procedure, Access will mess around with the byte code of the image (it converts it to bitmap). So, the only way is to store the exact binary code of the image in Access. For that you have to write some VBA code, or use another tool.
Once the image is fine in Access, you can display it with ASP easily:
<%
Response.ContentType = "image/GIF"
Set Conn = Server.CreateObject("ADODB .Connectio n")
Conn.ConnectionTimeout = 5
Conn.CommandTimeout = 5
Conn.Open "DSN=Images"
strSQL = "SELECT * FROM Table WHERE ID=" & Request.Querystring("ID")
Set RSImage = Conn.Execute(strSQL)
Response.Binarywrite RSImage("Image")
%>
Once the image is fine in Access, you can display it with ASP easily:
<%
Response.ContentType = "image/GIF"
Set Conn = Server.CreateObject("ADODB
Conn.ConnectionTimeout = 5
Conn.CommandTimeout = 5
Conn.Open "DSN=Images"
strSQL = "SELECT * FROM Table WHERE ID=" & Request.Querystring("ID")
Set RSImage = Conn.Execute(strSQL)
Response.Binarywrite RSImage("Image")
%>
ASKER
Ok...i know this code. My problem is how to store the image in the access database...in binary field and from vb6...
I use SA-FileUp from softartisans (www.softartisans.com) to store images into a database. I have seen it being done also with plain VBA. For that you have to use
AppendChunk.
Below follows a bit of code.
MyData.Edit
'Open Document
Open strFile For Binary As #1 ' Open file.
FileLength = LOF(1)
i = 0
Do While i < FileLength ' Loop until end of file.
i = i + 1
MyChar = InputB(1, #1) ' Get one byte.
MyData![Image].AppendChunk MyChar
Loop
Close #1 ' Close file.
MyData.Update
AppendChunk.
Below follows a bit of code.
MyData.Edit
'Open Document
Open strFile For Binary As #1 ' Open file.
FileLength = LOF(1)
i = 0
Do While i < FileLength ' Loop until end of file.
i = i + 1
MyChar = InputB(1, #1) ' Get one byte.
MyData![Image].AppendChunk
Loop
Close #1 ' Close file.
MyData.Update
ASKER
thank´s. do you know what kind of type must be the access field? submit an answer to glade you....
ASKER
i don´t need sa-fileup because i´m using a vb app to store the image in the database and next i upload the database to my www server.....and display the images with ASP´s...........
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I recommend that you just have a link to the imageand go from there.