DAO getchunk/appendchunk problems in Access 97 DB

DAO getchunk/appendchunk problems in Access 97 DB

Post by Douglas Will » Sat, 08 Jul 2000 04:00:00



A big thank you to anyone who can help!

I have a program that tracks personal information for employees and stores
this information in a Access97 database using DAO. I also take a picture of
the employee and include it in the database. The object is to store this
info and print a badge and personnel form. When the info is originally
collected, the data is collected and prints just fine. The problem occurs
either in my saving the picture OR retrieving the picture from my database.

I am  using the getchunk and appendchunk methods to store and retrieve the
photo from an OLE field in my database (code included below). All other data
is saved and retrieved from the databse just fine. The picture however is
causing me major gripes!

Based on the size growth of the database, it seems that the picture is being
stored, but I can't retieve the info and I don't know whether or not the
correct picture is being saved. Let me explain. I created a form to simply
scroll through each record in the DB. The first record loads and I disply
the picture just fine. As I move through the databse, all information is
updated correctly, except the picture. The same (or similar) picture is
displayed all of the time. I say same or similar because I write the picture
to a temporary file and then load it on my form. As I check the creation
date of the file, it is definitely being updated as I scroll through the
file. Another interesting thing is that the picture size for the first
record is 230,470 bytes, and in each subsequent record, the file size
increases by exactly 1 byte.

I'm stumped and the client is getting grouchy. I am sure that I am missing
something obvious, but I am to the point that I can't even read my own code.

Any help is greatly appreciated.

TIA

Doug

'************************************************************
' Here is where I begin to play around with the getchunk
' and appendchunk methods to save and retrieve a
' picture to and from a database
'************************************************************
'Saving the photo to the database
    Debug.Print "Entering write photo area."
    Dim strFileName As String
    strFileName = App.Path + "\Temp.bmp"
    Dim iFileNum As Integer
    iFileNum = FreeFile
    Dim iFileLength As Long
    Dim abBytes() As Byte
    Open strFileName For Binary Access Read As #iFileNum
    iFileLength = LOF(iFileNum)
    Debug.Print "Length of file is "; iFileLength
    ReDim abBytes(iFileLength)
    Get #iFileNum, , abBytes()
    tbInfo.Fields("Photo").AppendChunk (abBytes)
    Close iFileNum

' Retrieving the photo from the database

        Debug.Print "Entering read photo area"
        Dim stFileName As String
        Dim strFileName As String
        strFileName = App.Path + "\Temp.bmp"
        Dim iFileNum As Integer
        Dim iFileLength As Long
        Dim abBytes() As Byte
        iFileNum = FreeFile
        Open strFileName For Binary As #iFileNum
        iFileLength = LenB(tbInfo("Photo"))
        Debug.Print "Length of photo file is "; iFileLength
        ReDim abBytes(iFileLength)
        abBytes = tbInfo.Fields("Photo").GetChunk(0, iFileLength)
        Put #iFileNum, , abBytes()
        Close iFileNum
        End If

--
Where there's a Wills, there's a way!

 
 
 

1. DAO 2.5 to DAO 3.5 and Access 2.0 to Access 97 Answers and Questions (VB5)

I've inherited a rather huge amount of VB3.0 code over the last 6 months.
During that time I've moved the database engine from the great XBS200 Dbase
DLL that Jet provided to the mighty MSAJT200 Access DLL that also came with
VB3.0.  For a multiuser application, using Truegrid, using Crystal, (and
I'm really not pulling my hair out because I have MPB).

Fortunately, my employer has given me all the toys I've requested to move
this thing up a few generations (and a ticket to put this thing to sleep
permanently via a rewrite, but thats a much larger task).

Being brave I've tried to do this with VB5.  What I found:

1.  The default DAO module with an upgrade is the 2.5/3.0 compatibility
version.  Against an Access 2.0 database its actually slower.  Converting
the DB to Access 95 format improved performance, but not significantly.
Using this did not require a significant amount of code changes.  The main
one was is an empty string the same as null - this flipflopped yet again.
2.  The new 3.5 DAO module required a significant amount of work since the
code I got uses the Table object all over the place. I saw some performance
improvements (now about 20% of the original).

My Questions:

1.  It was not clear if moving to the new 3.5 DAO module without converting
to Access 97 format would make any difference (really, it was not clear if
there was any difference between the Access 97 and 95 formats).  Any news
on this?
2.  It was not clear if I would gain any locking (page vs. record-level)
advantages using DAO 3.5.  The help implied that a RecordSet object of Type
table still used page level locking.
3.  Unrelated, does anybody know of a report package that can print stuff
in fixed positions (within 1/16 inch) even if the printer type is changed -
this is for preprinted forms.  Also, does anyone know of a good substitute
for DBGrid that allows movable columns - this is an absolute requirement
with our product set.

Thanks,

George Raudabaugh

2. Help with ConnectCompelete Event

3. Problem reading strings from Access7 using getchunk/appendchunk/string datatype

4. *URGENT* AUDITDB Question

5. Problem with ADO, Getchunk and Appendchunk in SQL7 and VB6

6. Illegible Fonts

7. Weird problem with GetChunk/AppendChunk and BLOBs

8. JDBC and firewall

9. Converting Access 2.0 DB to Access 97 DB in VB code

10. DAO 3.6 Parameter Query Problems with Access 97 Format

11. Problems working with DAO and Access 97 and Win98 VB 5.0

12. Convert Access 97 DB to Access 2002 DB

13. ADOX/DAO create Access 97 on Windows 9X and Access on Windows XP