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
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.Write rsPhoto!Photo
mystream.SaveToFile "c:\\newimage.gif", adSaveCreateOverWrite

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


cnPhoto.Execute "DROP TABLE employee"
Exit Sub
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.

Nope, still not retrieving the *&%^ image. Will let all know when solved.

Have the same issue. Were you able to resolve this ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.