Results 1 to 23 of 23

Thread: Blob Sqlite3 vb6

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Blob Sqlite3 vb6

    Hi ..
    How i can save image
    from vb6 ADO to sqlite3 database
    So you know the sqlite database
    Havn't image field type
    Plz help me ..

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Blob Sqlite3 vb6

    I have only played with one OLEDB Provider for Sqlite3 and it seems to corrupt BLOB data, probably due to Sqlite's "everything is UTF-8 text" implementation.

    You might have to try a commercial paid product instead the has a proper workaround for binary data corruption.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Thank you dlettant ..
    How i can write the code when convert the pic to binary ..
    You have any sample .

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Blob Sqlite3 vb6

    I can't find any sample code right now but if I find it I will post something later.

  5. #5
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Blob Sqlite3 vb6

    Quote Originally Posted by dilettante View Post
    ... it seems to corrupt BLOB data, probably due to Sqlite's "everything is UTF-8 text" implementation.
    That's just another one of your many misleading statements about SQLite.

    Please read about the 5 supported storage-classes in SQLite:
    https://sqlite.org/datatype3.html

    Quote Originally Posted by dilettante View Post
    You might have to try a commercial paid product instead the has a proper workaround for binary data corruption.
    There is neither a workaround needed for BLOBs - nor is there a need for a "commercial product" -
    the official (free) ODBC-driver from Werner should do just fine - as does the COM-wrapper for SQLite (vbRichClient5).

    Olaf

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Blob Sqlite3 vb6

    Quote Originally Posted by Ami_Tech View Post
    How i can write the code when convert the pic to binary ..
    You have any sample .
    Here are examples (including Image-writing into BLOBs) for the SQLite-COM-wrapper:
    http://www.vbforums.com/showthread.p...ent-Framework)

    Olaf

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Thx ..
    Not done ,
    any one try maria db with vb6 ?

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Thx ..
    Not done ,
    any one try maria db with vb6 ?

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Blob Sqlite3 vb6

    Quote Originally Posted by Ami_Tech View Post
    Thx ..
    Not done ,
    What does "Not done" mean?

    Quote Originally Posted by Ami_Tech View Post
    ... any one try maria db with vb6 ?
    Yes.

    Olaf

  10. #10
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

    Re: Blob Sqlite3 vb6

    Quote Originally Posted by Ami_Tech View Post
    Hi ..
    How i can save image
    from vb6 ADO to sqlite3 database
    So you know the sqlite database
    Havn't image field type
    Plz help me ..
    Hi ,
    I don't know SQLite Database, in Access you can store an Image in a Memo Field
    does SQLite have a Memo Field Type?

    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  11. #11

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    ChrisE thank you ..
    Yes I've tried it with MS.Access
    also as said you already are.
    But there are SQLITE3 databases
    that contain only these types of fields
    how i can save pic as text ...
    or any way to see that in database SQLITE
    Attached Images Attached Images  

  12. #12

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Schmidt
    thank you
    Have you tried saving images in the mariadb and do you have an example?

  13. #13
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Blob Sqlite3 vb6

    Quote Originally Posted by Ami_Tech View Post
    Schmidt
    thank you
    Have you tried saving images in the mariadb and do you have an example?
    Sure, the answer is - in all cases (be it ADO/JET, ADO/PostgreSQL, ADO/MySQL, ADO/SQLite or vbRichClient5/SQLite):
    Code:
    MyRecordset.Fields("MyImgBlobField").Value = VBByteArray
    Just define the appropriate Table-Field-Type accordingly (in your "Create Table..." SQL-Statements, or your "DB-Manager-App" of choice).

    Olaf

  14. #14

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    ....

  15. #15
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Blob Sqlite3 vb6

    What's your actual question and what have you tried so far?

  16. #16

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Just i need any way to save image
    From vb6 to sqlite img field.

  17. #17

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Look here ..
    https://youtu.be/cxM_otRgFC8
    These sample in vb.net
    How i can convert code vb.net to vb6

  18. #18
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Blob Sqlite3 vb6

    Quote Originally Posted by Ami_Tech View Post
    Look here ..
    These sample in vb.net ...
    How i can convert code vb.net to vb6
    The COM-wrapper for SQLite requires far less code than what was shown in the .NET-based stuff, to handle the same scenario.

    First you will have to download and install the COM-wrapper:
    - Go to vbRichClient.com (into the Downloads-section) and download the Base-Libs of vbRichClient5.
    - Copy the vbRC5BaseDlls.zip Content into a Folder of your Choice (I use C:\RC5\ on my machines)
    - call the little install-script: RegisterRC5inPlace.vbs (or if you want to do it manually, call RegSvr32 for vbRichClient5.dll)

    After that is done, the rest becomes quite simple...
    Please ensure an empty VB-Std-Project and set a Reference to vbRichClient5 (over the References-Dialogue)

    Form-Code-Snippets:
    You will need a Connection-Object - and ensure an instance of it - followed by creating a Table inside your new DB:
    Code:
    Option Explicit
    
    Private Cnn As cConnection
    
    Private Sub Form_Load()
      Set Cnn = New_c.Connection(, DBCreateInMemory) 'establish the SQLite-Connection-Object
          Cnn.Execute "Create Table Images(ID Integer Primary Key, ImgName Text Collate NoCase, ImgBytes Blob)"
    End Sub
    So the above ensured a "Form-wide usable" Cnn-Instance (including the creation of a small Images-Table).

    Now two Helper-Routines, which can store a new Image-ByteArray in the table - or retrieve such a ByteArray from the Table:
    Code:
    Private Sub AddImageBytesToDB(ImgName As String, ImgBytes() As Byte)
      Dim Rs As cRecordset
      Set Rs = Cnn.OpenRecordset("Select * From Images Where 1=0")
          Rs.AddNew
          Rs!ImgName = ImgName
          Rs!ImgBytes = ImgBytes
          Rs.UpdateBatch
    End Sub
    
    Private Function GetImageBytesFromDB(ImgName As String) As Byte()
      Dim Rs As cRecordset
      Set Rs = Cnn.OpenRecordset("Select * From Images Where ImgName='" & ImgName & "'")
       If Rs.RecordCount Then GetImageBytesFromDB = Rs!ImgBytes
    End Function
    The above two functions are just simple wrappers around Recordset-based Table-Interactions
    (in most cases, working with the Recordsets directly is not that much more code to type...)

    With the Form_Load and the two Helper-Functions above present in your Form, we only need a bit of Demo-Code, which is started per Form_Click:
    Code:
    Private Sub Form_Click()
      'add some fresh downloaded Gif- and Png-Bytes to the DB-Table (under an image-name of your choice)
      AddImageBytesToDB "vbforums-logo.gif", DownloadImageFrom("http://www.vbforums.com/images/misc/logo.gif")
      AddImageBytesToDB "vbforums-search.png", DownloadImageFrom("http://www.vbforums.com/images/buttons/search.png")
     
      'visualize the DB-retrieved ImageBytes in the Forms Picture-Property (for vbforums-logo.gif)
      Set Picture = Cairo.CreateSurface(0, 0, , GetImageBytesFromDB("vbforums-logo.gif")).Picture
      MsgBox "You see the DB-retrieved Bytes of: vbforums-logo.gif"
     
      'and the same thing again (but for vbforums-search.png)
      Set Picture = Cairo.CreateSurface(0, 0, , GetImageBytesFromDB("vbforums-search.png")).Picture
      MsgBox "You see the DB-retrieved Bytes of: vbforums-search.png"
    End Sub
     
    Private Function DownloadImageFrom(URL As String) As Byte() 'just a little helper, returning raw-bytearrays from Web-content
      With New_c.Downloads
        If .Download(URL).WaitForCompletion(10) Then DownloadImageFrom = .Item(0).GetContentData
      End With
    End Function


    HTH


    Olaf

  19. #19

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Ok ..
    Thank you schmidt
    Just i want sample with vb6 and sqlite database in app.path
    To save and retrieve image blob
    Can you help me ..

  20. #20
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Blob Sqlite3 vb6

    What don't you understand about the samples given by Olaf?

    Instead of begging for more sample, show what you have tried based on those samples!

  21. #21

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Form include image command button save to database
    Databas sqlite in folder project path have image col blob
    and retrieve image command
    To Benefit and benefit others

  22. #22
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: Blob Sqlite3 vb6

    Here is another example, maybe Olaf has a better way.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by dreammanor; Jan 3rd, 2018 at 05:10 PM.

  23. #23

    Thread Starter
    Member
    Join Date
    Nov 2017
    Posts
    53

    Re: Blob Sqlite3 vb6

    Yes yes yes
    Thank you very ver very much .

Posting Permissions

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



Click Here to Expand Forum to Full Width