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.
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).
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.
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
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
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