I have followed every step in the My Sql forum posted - http://dev.mysql.com/tech-resources/articles/vb-blob-handling.html.

I have no problem in saving the picture file to MySql. The problem arises in retrieving the picture.

I am using code as follow: -

Private Sub DataLoadPicture()
    
On Error GoTo ErrFailed
    
Dim cnPhoto As New ADODB.Connection

Dim strIP As String

strIP = txtServerIP.Text

cnPhoto.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
            & "SERVER=" & strIP & ";" _
            & "DATABASE=ADMS;" _
            & "UID=root;" _
            & "PWD=;" _
            & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384

cnPhoto.CursorLocation = adUseClient
cnPhoto.Open
    
Dim rsPhoto As New ADODB.Recordset

Dim mystream As New ADODB.Stream
mystream.Type = adTypeBinary

rsPhoto.Open "SELECT * FROM employee WHERE employee.NewEmpNumber = 250", cnPhoto ', adOpenKeyset, adLockOptimistic
    
mystream.Open
mystream.Write rsPhoto!Photo
mystream.SaveToFile "c:\\newimage.gif", adSaveCreateOverWrite

imgPhoto.Picture = LoadPicture("c:\\newimage.gif")

mystream.Close
rsPhoto.Close

cnPhoto.Execute "DROP TABLE employee"
cnPhoto.Close
    
Exit Sub
    
ErrFailed:
MsgBox "The Employee Photo is either not saved or an error occurred in loading. " & err.Description, vbOKOnly + vbInformation, "Error In Loading Photo"
    
Exit Sub
End Sub

rsPhoto is loading correctly, because data is added to the text boxes.

I receive an error "Arguments are of the wrong type, are out of acceptable range or are in conflict with one another" error '3001'

If I take the "Mystream.Write RsPhoto!Photo" out, a file is saved under c:\ with obviously no bytes.

I have tried to change the picture types from jpg, gif to bmp. Again all saves fine, only the retrieval is generating errors.

Any ideas any one please.

This question has already been answered. Start a new discussion instead.