hi everyone, i have successfully saved the image file to DB by this code:
Private Sub cmdSave_Click()
Dim picsm As ADODB.Stream
Set picsm = New ADODB.Stream
picsm.Type = adTypeBinary
picsm.Open
picsm.LoadFromFile filepath
With rs
.AddNew
.Fields("Last") = txtLast.Text
.Fields("First") = txtFirst
.Fields("Pic") = picsm.Read
.Update
MsgBox "Successful"
End With
picsm.Close
Set picsm = Nothing
End Sub
But anyone can help me retrieve this image from DB and load it into the IMAGE CONTROL on the form?
i have this code:
Private Sub cmdSearch_Click()
Dim photo As String
squery = "select * from tblpic where Last='" & txtLast.Text & "'"
photo = rs.Fields("pic")
Set cm = New ADODB.Command
With cm
.ActiveConnection = conn
.CommandText = squery
.CommandType = adCmdText
End With
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockPessimistic
.Open cm
End With
With Me
.txtLast = rs!Last
.txtFirst = rs!First
.imgPic.Picture = LoadPicture(App.Path & "\pic\" & photo)
End With
End Sub
here is the error:
"file/path access error."
how could i retrieve the picture in the Access DB,
i think a folder must be reserved for the location of the photo.
thanks for the response.