dcsimg
Results 1 to 6 of 6

Thread: [vbRichClient] How to export BLOB image(jpg) from SQLite to file ?

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Posts
    18

    [vbRichClient] How to export BLOB image(jpg) from SQLite to file ?

    Hi

    I'm looking for a fast way to export all pictures from an SQLite database to *.jpg files.

    Regards

  2. #2
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,587

    Re: [vbRichClient] How to export BLOB image(jpg) from SQLite to file ?

    Assuming the BLOBs are JPEGS (that is, no conversion is needed), I think you should just be able to:


    • Open a connection to the SQLite database using the CConnection object. e.g. Set MyConnection = New_c.Connection.OpenDb("PathToMyDbFile")
    • Open a recordset from the appropriate table, with the BLOB column. e.g. Set MyRecordset = MyConnection.OpenRecordet("SELECT BLOBCOL FROM BLOBTABLE")
    • Put the BLOB field into a byte array. e.g. MyByteArray = MyRecordset.Fields(0).Value
    • Save the Byte Array using the RC% FSO object. e.g. New_c.FSO.WriteByteContent "Path\UniqueFilename.jpg", MyByteArray


    That's all just off the top of my head, untested so if it doesn't work, post any errors or problems you encounter and I'll take a closer look.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Posts
    18

    Re: [vbRichClient] How to export BLOB image(jpg) from SQLite to file ?

    Thank you jpbro, i'll try.

    Regards

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Posts
    18

    Re: [vbRichClient] How to export BLOB image(jpg) from SQLite to file ?

    Again...

    Private Sub mExport()
    Dim I As Long
    Dim Fld As String
    Dim BArray() As Byte
    '
    Fld = New_c.FSO.ShowFoldersDialog()
    If Fld = vbNullString Then Exit Sub
    '
    Screen.MousePointer = vbHourglass
    Set RS = CNX.OpenRecordset("Select * from [affiches]")
    For I = 0 To RSRSRS.RecordCount - 1
    BArray = RS!Thumb.Value
    New_c.FSO.WriteByteContent Fld & "\" & RS!ID.Value & ".jpg", BArray
    RS.MoveNext
    Next
    Screen.MousePointer = vbDefault
    MsgBox "Successfull Export of " & RS.RecordCount & " items.", vbInformation + vbOKOnly
    End Sub

    That's really Fast !

  5. #5
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    374

    Re: [vbRichClient] How to export BLOB image(jpg) from SQLite to file ?

    An it should be a lot faster if you move FSO instantiation outside the loop

    Code:
    Set oFSO = New_c.FSO
    
    For I = 0 To RS.RecordCount - 1
       BArray = RS!Thumb.Value
       oFSO.WriteByteContent Fld & "\" & RS!ID.Value & ".jpg", BArray
       RS.MoveNext
    Next
    Carlos

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Posts
    18

    Re: [vbRichClient] How to export BLOB image(jpg) from SQLite to file ?

    Thank you Carlos it's true !

    If Microsoft knew what becomes vb6 with vbRichClient they would reconsider the issue may be ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width