Weird problem with GetChunk/AppendChunk and BLOBs

Weird problem with GetChunk/AppendChunk and BLOBs

Post by David J. Surl » Tue, 05 Jan 1999 04:00:00



I have a VB 5.0 application which uses DAO and AppendChunk/GetChunk to
store/retrieve bitmaps in an Access/JET database.  I have the application
running on two different PCs:  one has Windows 95, VB 5.0, and Office 97
(including Access) installed on it; the other has Windows 98 and VB 5.0, but
not Office/Access.  I have a database in which I stored some bitmap images
from the application running on one machine, and some images from the
application running on the other machine.  When I try to read the data from
the Long Binary field into Image controls (via GetChunk), I can only see the
images which were stored in the database by the app on the same machine --
the others are completely garbled.  When I read the images into the controls
from the app running on the other machine, it's the same problem -- now I
can only see the images which were also saved from that machine.  Those
images which were saved from the other machine are garbled.

Anyone have any ideas?

I have SP-3 installed on both machines.  It seems the only difference is
Windows 95 vs. 98; and whether or not Office/Access is installed.

Thanks in advance for the help!!

 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by C.M. » Tue, 05 Jan 1999 04:00:00



> I have a VB 5.0 application which uses DAO and AppendChunk/GetChunk to
> store/retrieve bitmaps in an Access/JET database.  I have the application
> running on two different PCs:  one has Windows 95, VB 5.0, and Office 97
> (including Access) installed on it; the other has Windows 98 and VB 5.0, but
> not Office/Access.  I have a database in which I stored some bitmap images
> from the application running on one machine, and some images from the
> application running on the other machine.  When I try to read the data from
> the Long Binary field into Image controls (via GetChunk), I can only see the
> images which were stored in the database by the app on the same machine --
> the others are completely garbled.  When I read the images into the controls
> from the app running on the other machine, it's the same problem -- now I
> can only see the images which were also saved from that machine.  Those
> images which were saved from the other machine are garbled.

> Anyone have any ideas?

> I have SP-3 installed on both machines.  It seems the only difference is
> Windows 95 vs. 98; and whether or not Office/Access is installed.

> Thanks in advance for the help!!

I am familiar with a SP-3 for NT but assume you mean for VB? Just wondering if
my own VB is running behind.

 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by David Keeve » Tue, 05 Jan 1999 04:00:00



>I have a VB 5.0 application which uses DAO and AppendChunk/GetChunk to
>store/retrieve bitmaps in an Access/JET database.  I have the application
>running on two different PCs:  one has Windows 95, VB 5.0, and Office 97

<snip>

Quote:>images which were saved from the other machine are garbled.

>Anyone have any ideas?

Are the two machines running the same display setup? That is, is one
set for 24 Truecolor vs 16 High color on the the other? That was the fix
for me (make both same settings) when I had this problem with a setup
similar to yours.

Dave Keever

 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by David J. Surl » Wed, 06 Jan 1999 04:00:00


Thanks, David.  A great idea, but apparently that isn't it either.  They
were indeed running different display settings, but when I synchronized them
I still got the same problem.  With both machines running lower resolution
(256 colors, 800 x 600) the images were legible -- the colors were just not
right (looked sort of like a photo negative).

In contrast, the problem I am having is that images saved on the other
machine are completely garbled so that you can't even tell what the image is
supposed to be.  It's just a smattering of horizontal bars of color.

Any other ideas out there?


>Are the two machines running the same display setup? That is, is one
>set for 24 Truecolor vs 16 High color on the the other? That was the fix
>for me (make both same settings) when I had this problem with a setup
>similar to yours.

>Dave Keever


 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by jz.. » Thu, 07 Jan 1999 04:00:00


I, too, am having this same problem.  I have no solutions yet, just
more symptoms, here they are:

When a machine running Windows 98 writes blob data (i.e. image data)
to the database (using AppendChunk) Windows 95 and Windows NT 4.0
machines can not read that data (using GetChunk) without it being
"garbled". But 98 can read it fine.

When a machine running Windows 95 or NT 4.0 writes blob data (i.e.
image data) to the database (using AppendChunk) Windows 98 machines
can not read that data (using GetChunk) without it being "garbled".
But 95 and 4.0 can read it fine.

This is a problem only with ADO 2.0 and 2.1.  ADO 1.5 Works fine
across all systems.

This problems occurrs with SQL Server 6.5, SQL Server 7.0, and Access
97.

So this doesn't help more, but it's all  I have right now.

Jeremey Zela

On Mon, 4 Jan 1999 17:13:29 -0500, "David J. Surls"


>I have a VB 5.0 application which uses DAO and AppendChunk/GetChunk to
>store/retrieve bitmaps in an Access/JET database.  I have the application
>running on two different PCs:  one has Windows 95, VB 5.0, and Office 97
>(including Access) installed on it; the other has Windows 98 and VB 5.0, but
>not Office/Access.  I have a database in which I stored some bitmap images
>from the application running on one machine, and some images from the
>application running on the other machine.  When I try to read the data from
>the Long Binary field into Image controls (via GetChunk), I can only see the
>images which were stored in the database by the app on the same machine --
>the others are completely garbled.  When I read the images into the controls
>from the app running on the other machine, it's the same problem -- now I
>can only see the images which were also saved from that machine.  Those
>images which were saved from the other machine are garbled.

>Anyone have any ideas?

>I have SP-3 installed on both machines.  It seems the only difference is
>Windows 95 vs. 98; and whether or not Office/Access is installed.

>Thanks in advance for the help!!

 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by Mark Hise » Thu, 07 Jan 1999 04:00:00


I probably don't have the exact answer you need, but I did struggle with
a similar problem. What worked for me was to use a data control and load
the image into the table by loading it into a picture box. The data
control then moved it into the table. The data control also displayed
the image back into the picture box for me.

I don't know about one machine versus another, I gave up on append chunk
rather quickly when my initial tests didn't look too good.


> I, too, am having this same problem.  I have no solutions yet, just
> more symptoms, here they are:

> When a machine running Windows 98 writes blob data (i.e. image data)
> to the database (using AppendChunk) Windows 95 and Windows NT 4.0
> machines can not read that data (using GetChunk) without it being
> "garbled". But 98 can read it fine.

> When a machine running Windows 95 or NT 4.0 writes blob data (i.e.
> image data) to the database (using AppendChunk) Windows 98 machines
> can not read that data (using GetChunk) without it being "garbled".
> But 95 and 4.0 can read it fine.

> This is a problem only with ADO 2.0 and 2.1.  ADO 1.5 Works fine
> across all systems.

> This problems occurrs with SQL Server 6.5, SQL Server 7.0, and Access
> 97.

> So this doesn't help more, but it's all  I have right now.

> Jeremey Zela

> On Mon, 4 Jan 1999 17:13:29 -0500, "David J. Surls"

> >I have a VB 5.0 application which uses DAO and AppendChunk/GetChunk to
> >store/retrieve bitmaps in an Access/JET database.  I have the application
> >running on two different PCs:  one has Windows 95, VB 5.0, and Office 97
> >(including Access) installed on it; the other has Windows 98 and VB 5.0, but
> >not Office/Access.  I have a database in which I stored some bitmap images
> >from the application running on one machine, and some images from the
> >application running on the other machine.  When I try to read the data from
> >the Long Binary field into Image controls (via GetChunk), I can only see the
> >images which were stored in the database by the app on the same machine --
> >the others are completely garbled.  When I read the images into the controls
> >from the app running on the other machine, it's the same problem -- now I
> >can only see the images which were also saved from that machine.  Those
> >images which were saved from the other machine are garbled.

> >Anyone have any ideas?

> >I have SP-3 installed on both machines.  It seems the only difference is
> >Windows 95 vs. 98; and whether or not Office/Access is installed.

> >Thanks in advance for the help!!

 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by Simon Capstic » Fri, 08 Jan 1999 04:00:00


I do the same using the OLE object container control.  I also gave up on
AppendChunk and now my OLE objects are inserted/exported from the Db via an
OLE control on a VB form.

Simon C


>I probably don't have the exact answer you need, but I did struggle with
>a similar problem. What worked for me was to use a data control and load
>the image into the table by loading it into a picture box. The data
>control then moved it into the table. The data control also displayed
>the image back into the picture box for me.

 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by Jerr » Wed, 13 Jan 1999 04:00:00


Hi

I've had a similar problem with DAO 3.51.
I was using a temporary file for storing images retrived with getchunk from
the SQL Server or MS Access before displaying it.
After few hours of testing I've noticed that the "errorous" behavior was
coused by type of buffer used to receive data. After declaring it as an
array of bytes instead of array of strings "error" dissapeared. This was
coused by Unicode conversion of the string buffer written to file.

Now the procedures looks like this:

Public Function CopyFieldToFile(fd As Field) As String

Dim tmpFileName As String
Dim FileNum As Integer
Dim Buffer() As Byte

Dim BytesNeeded As Long
Dim Buffers As Long
Dim Remainder As Long
Dim Offset As Long
Dim r As Integer
Dim i As Long
Static Count As Long

    BytesNeeded = fd.FieldSize
    If BytesNeeded > 0 Then
       ' Calculate the number of buffers needed to copy
        Buffers = BytesNeeded \ ChunkSize
        Remainder = BytesNeeded Mod ChunkSize

        ' Get a unique, temporary filename:
        Count = Count + 1
        tmpFileName = App.path & "\tmp" & Count & ".tif"
        If Dir(tmpFileName) <> "" Then
            Kill tmpFileName
        End If

        ' Copy the bitmap to the temporary file chunk by chunk:
        FileNum = FreeFile
        Open tmpFileName For Binary As #FileNum

        For i = 0 To Buffers - 1
           ReDim Buffer(ChunkSize)
           Buffer = fd.GetChunk(Offset, ChunkSize)
           Put #FileNum, , Buffer()

           Offset = Offset + ChunkSize
        Next

        ' Copy the remaining chunk of the bitmap to the file:
        ReDim Buffer(Remainder)
        Buffer = fd.GetChunk(Offset, Remainder)
        Put #FileNum, , Buffer()
        Close #FileNum

    End If

    CopyFieldToFile = Trim(tmpFileName)

End Function

Private Sub CopyFileToField(FileName As String, fd As Field)

Dim ChunkSize As Long
Dim FileNum As Integer
Dim Buffer()  As Byte
Dim BytesNeeded As Long
Dim Buffers As Long
Dim Remainder As Long

Dim i As Long

    If Len(FileName) = 0 Then
        Exit Sub
    End If

    If Dir(FileName) = "" Then
        Err.Raise vbObjectError, , "Nie odnaleziono pliku: """ & FileName &
""""
    End If

    ChunkSize = 65536

    FileNum = FreeFile

    Open FileName For Binary As #FileNum

    BytesNeeded = LOF(FileNum)
    Buffers = BytesNeeded \ ChunkSize
    Remainder = BytesNeeded Mod ChunkSize

    For i = 0 To Buffers - 1
        ReDim Buffer(ChunkSize)
        Get #FileNum, , Buffer
        fd.AppendChunk Buffer
    Next

    ReDim Buffer(Remainder)
    Get #FileNum, , Buffer
    fd.AppendChunk Buffer

    Close #FileNum

End Sub

Happy programing


>I have a VB 5.0 application which uses DAO and AppendChunk/GetChunk to
>store/retrieve bitmaps in an Access/JET database.  I have the application
>running on two different PCs:  one has Windows 95, VB 5.0, and Office 97
>(including Access) installed on it; the other has Windows 98 and VB 5.0,
but
>not Office/Access.  I have a database in which I stored some bitmap images
>from the application running on one machine, and some images from the
>application running on the other machine.  When I try to read the data from
>the Long Binary field into Image controls (via GetChunk), I can only see
the
>images which were stored in the database by the app on the same machine --
>the others are completely garbled.  When I read the images into the
controls
>from the app running on the other machine, it's the same problem -- now I
>can only see the images which were also saved from that machine.  Those
>images which were saved from the other machine are garbled.

>Anyone have any ideas?

>I have SP-3 installed on both machines.  It seems the only difference is
>Windows 95 vs. 98; and whether or not Office/Access is installed.

>Thanks in advance for the help!!

 
 
 

Weird problem with GetChunk/AppendChunk and BLOBs

Post by David J. Surl » Sat, 16 Jan 1999 04:00:00


Thanks, Jerry; that did it!!

Two follow-up questions:
1)  Is there a performance problem or advantage to using byte arrays rather
than strings?

2)  Is there a way to "convert" fields in databases which were written using
strings?  In particular, I need to be able to read a field on a Windows
98/NT machine which was written (to a temp file) using strings on a Windows
95 machine, then write it back to the field using the byte array method you
described.  Do you know how?

Thanks for the help!!