I write binary data from pictures into my SQLite database into a BLOB field called "icondata".
CREATE TABLE pictures(id INTEGER PRIMARY KEY AUTOINCREMENT, icondata BLOB)
The code snippet to write the binary data is:
SQLcommand.CommandText = "INSERT INTO pictures (id, icondata) VALUES (" & MyInteger & "," & "@img)"
SQLcommand.Prepare()
SQLcommand.Parameters.Add("@img", DbType.Binary, PicData.Length)
SQLcommand.Parameters("@img").Value = PicData
This works fine and I can find the BLOB values in the database using a tool like SQlite Spy.
But how can I search for a specific "icondata" BLOB?
If I try it with:
SQLcommand.CommandText = "SELECT id FROM pictures WHERE icondata=@img"
and with the same Parameters like above:
SQLcommand.Prepare()
SQLcommand.Parameters.Add("@img", DbType.Binary, PicData.Length)
SQLcommand.Parameters("@img").Value = PicData
Dim SQLreader As SQLite.SQLiteDataReader = SQLcommand.ExecuteReader()
While SQLreader.Read()
... Process found database entries....
End While
I don't get any result.
If I change the SELECT query to 'LIKE' instead of '=' I get all entries with BLOBs, not only the matching one.
How do I have to write the SELECT query to find the 1 exactly matching entry for a specific BLOB?
id
?! – Broider