Re: Problem retrieving images from Access 2003 Binary Large Object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
> >
> >
.



Relevant Pages

  • Re: Running a stored ASP code. Is it possible?
    ... >Can I store an ASP code that will be executed on the server side in that db? ... >My asp page is accessing the “site” db, reading the asp code, executing it. ... The database has ASP code, ...
    (microsoft.public.inetserver.asp.db)
  • Forms abd Database
    ... I am trying to send info to a database ... page is .htm I am suppose to change ... this to .asp. ... I reading this wrong? ...
    (microsoft.public.frontpage.programming)
  • Adding carriage returns in asp:listbox
    ... In ASP .NET I have a listbox like this, ... I want to add items to the listbox (which I am reading out of a ... database). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Application Speed Problem - VERY weird
    ... MDE front ends not MDB ... If the DB is reading in a lot of records, ... The data is linked with the standard Access "link ... add that we have only ever used the database on Access 2K. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Help with calculations in a query
    ... Well, Richard, I'll tell you what I do know. ... I do know that I've tried various approaches to solving many database ... deletes the row containing the previous day's reading? ... Lets say that I created an extra field in my table for each meter ...
    (microsoft.public.access.queries)