Using AppendChunk To Store Image As BLOB In Table (1 Viewer)

VSCurtis

New member
Local time
Yesterday, 20:07
Joined
Mar 8, 2021
Messages
5
Hi Guys

I was wondering if someone would be so kind as to post a working code snippet using appendchunk to store an image as a BLOB in a table. I used to have a working piece of code but I seem to have lost the database and I cannot find an example on the net. I know I am going to hear a lot of feedback about it not being a good idea. With all due respect I did not post this to hear your opinions, I posted it because this is what I want to do and this is how I choose to do it. I'm not trying to be rude just putting an end to a debate before it begins. There are only 1000 records in this table and the database is a prototype and will be migrated to SQL Server once I have finished scrubbing the data. The database is a Media Database and the images are album art. They are small and should not be a big issue.

Thanks In Advance
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:07
Joined
May 7, 2009
Messages
19,246
just use an Attachment field?
saving to this field type is straight forward.
 

VSCurtis

New member
Local time
Yesterday, 20:07
Joined
Mar 8, 2021
Messages
5
Thanks for your input but obviously you DID NOT read my post. I specifically stated what I was looking for. I also stated that I WAS NOT interested in other opinions or options.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:07
Joined
May 7, 2009
Messages
19,246
yes i did not read your post.
if you continue with that path and your OS is windows 8 or better,
you'll end up having "Package" or long Binary to your Blob field.
which Cannot be displayed the "actual" image.

just ignore my post as if it was not offered.
 

VSCurtis

New member
Local time
Yesterday, 20:07
Joined
Mar 8, 2021
Messages
5
yes i did not read your post.
if you continue with that path and your OS is windows 8 or better,
you'll end up having "Package" or long Binary to your Blob field.
which Cannot be displayed the "actual" image.

just ignore my post as if it was not offered.
This is PRECISELY why I worded my post the way I did. There is always someone like YOU who can't resist offering their two cents even when asked NOT to. The image CAN be displayed. I have done it
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:07
Joined
May 7, 2009
Messages
19,246
Code:
Private Const BLOCK_SIZE = 16384

'Function:  BlobToFile - Extracts the data in a binary field to a disk file.
'Parameter: strFile - Full path and filename of the destination file.
'Parameter: Field - The field containing the blob.
'Return:    The length of the data extracted.
Public Function BlobToFile(strFile As String, ByRef Field As Object) As Long
    On Error GoTo BlobToFileError

    Dim nFileNum As Integer
    Dim abytData() As Byte
    BlobToFile = 0
    nFileNum = FreeFile
    Open strFile For Binary Access Write As nFileNum
    abytData = Field
    Put #nFileNum, , abytData
    BlobToFile = LOF(nFileNum)

BlobToFileExit:
    If nFileNum > 0 Then Close nFileNum
    Exit Function

BlobToFileError:
    MsgBox "Error " & Err.Number & ": " & Err.description, vbCritical, _
           "Error writing file in BlobToFile"
    BlobToFile = 0
    Resume BlobToFileExit

End Function


'Function:  FileToBlob - Loads a file into a binary field.
'Parameter: strFile - Full path and filename of the source file.
'Parameter: Field - The binary field into which the file is to be loaded.
Public Function FileToBlob(strFile As String, ByRef Field As Object)
    On Error GoTo FileToBlobError

    If Len(Dir(strFile)) > 0 Then
        Dim nFileNum As Integer
        Dim byteData() As Byte

        nFileNum = FreeFile()
        Open strFile For Binary Access Read As nFileNum
        If LOF(nFileNum) > 0 Then
            ReDim byteData(1 To LOF(nFileNum))
            Get #nFileNum, , byteData
            Field = byteData
        End If
    Else
        MsgBox "Error: File not found", vbCritical, _
               "Error reading file in FileToBlob"
    End If

FileToBlobExit:
    If nFileNum > 0 Then Close nFileNum
    Exit Function

FileToBlobError:
    MsgBox "Error " & Err.Number & ": " & Err.description, vbCritical, _
           "Error reading file in FileToBlob"
    Resume FileToBlobExit

End Function
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:07
Joined
May 7, 2009
Messages
19,246
here is always someone like YOU who can't resist offering their two cents even when asked NOT to.
like i said, you can always Ignore me. As if i never existed in this forum since 2009.
 

VSCurtis

New member
Local time
Yesterday, 20:07
Joined
Mar 8, 2021
Messages
5
like i said, you can always Ignore me. As if i never existed in this forum since 2009.
Thank you for addressing my post directly. Much appreciated although your code does not use appendchuck.
 

FrankRuperto

Member
Local time
Yesterday, 20:07
Joined
Mar 6, 2021
Messages
182
like i said, you can always Ignore me. As if i never existed in this forum since 2009.
arnelgp is one of the most knowledgeable and helpful memebrs I have ever encountered in forums, so his valuable feedback is always welcome in my book.
 

NauticalGent

Ignore List Poster Boy
Local time
Yesterday, 20:07
Joined
Apr 27, 2015
Messages
6,369
I don't know much about appendages, chunky monkies, and what not...

But I gotta say that I already like the person at MS who developed this method...on choice of naming alone. Succinct and leaved nothing to interpretation!

And for VSCurtis: while it is true that most of the members here want to build you a watch rather than tell you what time it is, it comes from years of helping those who have come before you and just like you THINK you know what is it is you want instead of what you need. YOU chose to come here for advice and it was given...for FREE. What you have done now is probably ward off any further assistance from anyone else. Friendly, FREE advice...take it or leave it.
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:07
Joined
Jul 9, 2003
Messages
16,285
This is PRECISELY why I worded my post the way I did. There is always someone like YOU who can't resist offering their two cents even when asked NOT to. The image CAN be displayed. I have done it

The only explanation I can think for the very Odd attitude of this poster is that they've posted somewhere else and had their wrist slapped! Seems to me they now need their bum smacked! What a baby!
 

Users who are viewing this thread

Top Bottom