Outputting a bitmap from an Access database
Outputting a bitmap from an Access database
am 07.08.2007 16:00:26 von jason
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
Re: Outputting a bitmap from an Access database
am 08.08.2007 12:52:29 von Daniel Crichton
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
> 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
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
Re: Outputting a bitmap from an Access database
am 08.08.2007 14:26:32 von jason
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
On Aug 8, 6:52 am, "Daniel Crichton" wrote:
> 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 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
>
> 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 -
Re: Outputting a bitmap from an Access database
am 09.08.2007 14:20:50 von Daniel Crichton
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
> On Aug 8, 6:52 am, "Daniel Crichton" wrote:
>> 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
>>> 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
>> 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 -