Re: Problem retrieving images from Access 2003 Binary Large Object
- From: Julian <Julian@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 13 Jan 2006 07:49:02 -0800
Hi Paul!
Would you please send me the modified functions for reading and writing in
order to store the JPG files in my database without the overhead?
Thanks in advance for your help,
Julian
julianet@xxxxxxx
"Paul H" wrote:
> Changing the strings to byte arrays has fixed the problem.
>
> Thanks
>
> --
> Paul H.
>
>
> "bob" wrote:
>
> >
> >
> > ReadBlob/WriteBlob use string functions, which causes the doubling of size. Eliminate the string functions
> > and you will avoid the conversion & extra storage and will be able to work with the data directly in ASP
> > as you require.
> >
> > --
> > _______________________________________________________
> > http://www.ammara.com/
> > Image Handling Components, Samples, Solutions and Info
> > DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous
> >
> >
> >
> > =?Utf-8?B?UGF1bCBI?= <PaulH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > >I can write and read jpeg images to/from MS Access table BLOB fields using
> > >the ReadBlob and Write Blob functions recommended in
> > >http://support.microsoft.com/?kbid=210486, and the retrieved image can be
> > >displayed in an MS access form image field.
> > >
> > >If I connect to the Access database from an ASP page and read the BLOB field
> > >using ADO.NET functions the returned file is twice the size of the file
> > >returned when reading the BLOB field using MS Access, and it cannot be
> > >displayed.
> > >
> > >The code for reading the BLOB field is listed below and copied from
> > >http://support.microsoft.com/default.aspx?scid=kb;en-us;326502 .
> > >
> > >Can you suggest what may be causing this problem.
> > >
> > >
> > >
> > >Comparing the contents of the two jpeg files returned it appears that each
> > >byte in the original file is converted to two bytes when stored in the MS
> > >access table. If the data is read back using the MS access WriteBLOB function
> > >then each pair of bytes is correctly reconverted back to one byte with the
> > >original value.
> > >
> > >When the BLOB is read from the ASP page this does not happen. I tried
> > >removing the most signifant byte of each pair of bytes and creating a file of
> > >the original size but the picture could still not be displayed.
> > >
> > >Further examination of the file contents showed that the most of the least
> > >significant bytes of each pair contained the original value but occasionally
> > >they did not and there is a value in the most significant byte.
> > >
> > ><%@ Page Language="VB" Debug="true" ContentType="text/html"
> > >ResponseEncoding="iso-8859-1" %>
> > ><%@Import Namespace="System.Data" %>
> > ><%@Import Namespace="System.IO" %>
> > ><%
> > >Dim PictureCol As Integer = 0 ' the column # of the BLOB field
> > >
> > >Dim cn As New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data
> > >Source=C:\Inetpub\wwwroot\PaulsWebASPNet\LakeDistrictFells2000.mdb")
> > >
> > >Dim cmd As New OleDbCommand("SELECT photo FROM tblPhoto WHERE
> > >PhotoNumber=2", cn)
> > >
> > >cn.Open()
> > >
> > >Dim dr As OleDbDataReader = cmd.ExecuteReader()
> > >dr.Read()
> > >
> > >Dim b(dr.GetBytes(PictureCol, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte
> > > dr.GetBytes(PictureCol, 0, b, 0, b.Length)
> > > dr.Close()
> > > cn.Close()
> > >
> > >‘***** start of temporary code ******
> > >Dim fs As New
> > >System.IO.FileStream("C:\Inetpub\wwwroot\paulsWebaspNet\test2.jpg",
> > >IO.FileMode.Create, IO.FileAccess.Write)
> > > fs.Write(b, 0, b.Length)
> > > fs.Close()
> > >‘***** end of temporary code ******
> > >
> > >'Response.Expires = 0
> > >'Response.Buffer = TRUE
> > >'Response.Clear
> > >'Response.ContentType = "image/jpg"
> > >'Response.BinaryWrite(b)
> > >'Response.End
> > >
> > >%>
> > >
> > >--
> > >Paul H.
> >
> >
.
- Follow-Ups:
- Re: Problem retrieving images from Access 2003 Binary Large Object
- From: Stephen Lebans
- Re: Problem retrieving images from Access 2003 Binary Large Object
- Prev by Date: Re: Broken or missing reference
- Next by Date: Re: How do I resolve a compile error that I get after conversion?
- Previous by thread: Re: Broken or missing reference
- Next by thread: Re: Problem retrieving images from Access 2003 Binary Large Object
- Index(es):
Relevant Pages
|