-
VB6 MySQL BLOB
I am trying to post a .jpg file as a BLOB field in a MySQL database.
The following code does not error, but the result is a NULL in the field.
Dim rs As New ADODB.Recordset
Dim mystream As New ADODB.Stream
mystream.Type = adTypeBinary
rs.Open "SELECT Image FROM tblDRSImages WHERE ID = 0", cnCP, adOpenDynamic, adLockOptimistic
rs.AddNew
mystream.Open
mystream.LoadFromFile "F:\dating.jpg"
rs!Image = mystream.Read
rs.Update
rs.Close
mystream.Close
However the next code block works, if I insert an image into the field using TOAD:
rs.Open "SELECT Image FROM tblDRSImages WHERE ID = 5", cnCP
mystream.Open
mystream.Write rs.Fields(0)
mystream.SaveToFile "F:\datingTest.jpg", adSaveCreateOverWrite
rs.Close
mystream.Close