Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / August 2007



Tip: Looking for answers? Try searching our database.

Outputting a bitmap from an Access database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jason@careermatrix.com - 07 Aug 2007 15:00 GMT
I have an access database with a field of "OLE Object" that has
bitmaps. I'm trying to output these bitmaps to an ASP page viewed in a
webbrowser.
This is how I'm attempting to do this now:
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=GLGInventory"

strSQL = "SELECT * FROM TableWebThumbs WHERE ID = " &
Request.QueryString("ID") & ""
Set rst = conn.Execute(strSQL)

Response.ContentType = "image/bmp"
' let the browser know the file name
'Response.AddHeader "Content-Disposition", "attachment;filename=" &
Trim(rs("filename"))
' let the browser know the file size
'Response.AddHeader "Content-Length", rs("filesize")
Response.BinaryWrite rst("Thumbnail").value

rst.Close
Set rst = nothing
conn.Close
Set conn = nothing
%>

I get a nice red X for an unknown image.
Any ideas would be helpful.

Jason
Daniel Crichton - 08 Aug 2007 11:52 GMT
jason@careermatrix.com wrote  on Tue, 07 Aug 2007 07:00:26 -0700:

> I have an access database with a field of "OLE Object" that has
> bitmaps. I'm trying to output these bitmaps to an ASP page viewed in a
[quoted text clipped - 3 lines]
> Set conn = Server.CreateObject("ADODB.Connection")
> conn.Open "DSN=GLGInventory"

> strSQL = "SELECT * FROM TableWebThumbs WHERE ID = " &
> Request.QueryString("ID") & ""
> Set rst = conn.Execute(strSQL)

> Response.ContentType = "image/bmp"
> ' let the browser know the file name 'Response.AddHeader
[quoted text clipped - 3 lines]
> "Content-Length", rs("filesize")
> Response.BinaryWrite rst("Thumbnail").value

> rst.Close
> Set rst = nothing conn.Close
> Set conn = nothing %>

> I get a nice red X for an unknown image.
> Any ideas would be helpful.

> Jason

First thing I'd suggest is make sure that the data is a valid bitmap. Use an
application that can save a response directly to a file to your hard disk
and then try to open it with a graphics application. Also looking into the
chunk methods for putting data into the database and retrieving data, using
.Value might be resulting in data truncation.

Second thing is to not use bitmaps - they're not globally supported by
browsers, and even RLE compressed will rarely, if ever, be as small as a GIF
or JPEG of the same image.

Dan
jason@careermatrix.com - 08 Aug 2007 13:26 GMT
My client had an existing database that they wanted displayed on the
web.  I have no control over the format of the images, I just know the
images are bitmaps.
The images are bitmaps that will open with Microsoft Paint.
Removing .value still gives the red X.

Any other ideas?

Jason

> ja...@careermatrix.com wrote  on Tue, 07 Aug 2007 07:00:26 -0700:
>
[quoted text clipped - 35 lines]
>
> - Show quoted text -
Daniel Crichton - 09 Aug 2007 13:20 GMT
jason@careermatrix.com wrote  on Wed, 08 Aug 2007 05:26:32 -0700:

> My client had an existing database that they wanted displayed on the
> web.  I have no control over the format of the images, I just know the
> images are bitmaps.
> The images are bitmaps that will open with Microsoft Paint.
> Removing .value still gives the red X.

> Any other ideas?

> Jason

I didn't say remove .value (it's the default property of a field object, so
actually isn't required anyway in most uses). I said to look at the chunk
methods - specifically GetChunk in this case. This is used to retrieve data
from a large field (normally Text or Image in Access) in chunks, so
bypassing any implicit conversion using the .Value property.

And just because you know they are bitmaps, it doesn't mean they've been
stored properly in the database. If you mean that they can be displayed by
other application(s) that uses the same database, then look at how they are
retrieving the data to see if they do it differently to your method.

Dan

>> ja...@careermatrix.com wrote  on Tue, 07 Aug 2007 07:00:26 -0700:

>>> I have an access database with a field of "OLE Object" that has
>>> bitmaps. I'm trying to output these bitmaps to an ASP page viewed in
[quoted text clipped - 18 lines]
>>> Any ideas would be helpful.
>>> Jason

>> First thing I'd suggest is make sure that the data is a valid bitmap.
>> Use an application that can save a response directly to a file to
>> your hard disk and then try to open it with a graphics application.
>> Also looking into the chunk methods for putting data into the
>> database and retrieving data, using .Value might be resulting in data
>> truncation.

>> Second thing is to not use bitmaps - they're not globally supported
>> by browsers, and even RLE compressed will rarely, if ever, be as
>> small as a GIF or JPEG of the same image.

>> Dan- Hide quoted text -

>> - Show quoted text -
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.