OK, I got the recordset to read from the stream.
I also got the recordset to write to the SQL image field
Only problem left: the SQL field now won't display the image, as it seems to
be the wrong data format!!
Code:-
=====
(Please note: this has been tested with BMP, JPG & GIF files)
Public Sub SaveImage(strFile As String)
Dim fLen As Integer
Dim bytes() As Byte
Dim f As Field
Dim s As Stream
Set s = New Stream
Dim mstream As ADODB.Stream
'Get file contents into stream
Set mstream = New ADODB.Stream
With mstream
.Type = adTypeBinary
.Open
.LoadFromFile strFile
End With
' Get the stream contents into the field
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
' Initialise and instantiate the rs recordset object then ...
With rs
rs.Open "Select * from photos where ph_compno=42346",
CurrentProject.Connection, adOpenDynamic, adLockPessimistic
rs.Fields("ph_photo").Value = mstream.Read
rs.Update
End With
rs.Close
End Sub