Ok I think this will do the job.
1. Create the OLE Field in the Table
2. Open the table as Recordset in VB
3. Create a loop for each line in the recordset
Code:'In RS loop success = Img_FileIntoField(rs,rs.Fields("ole_name"),rs!filename) Public Function Img_FileIntoField(rs As Recordset, fldLongBinary As Field, sFilename As String) As Boolean On Error GoTo 100: Dim iFN As Integer Dim lFileLen As Long Dim sChunk As String With fldLongBinary If .Type = dbLongBinary Then 'only long binary supported ' On Error GoTo StoreFileIntoFieldEH rs.Edit 'edit the record in the recordset .Value = "" 'clear the field rs.Update 'update the record rs.Edit 'now edit again iFN = FreeFile 'get a file handle Open sFilename For Binary As #iFN lFileLen = LOF(iFN) While lFileLen > 0 'loop until finished If mclChunkSize < lFileLen Then 'chunk smaller than remaining sChunk = String$(mclChunkSize, vbNullChar) Else 'chunk larger than remaining sChunk = String$(lFileLen, vbNullChar) End If Get #iFN, , sChunk 'get a chunk .AppendChunk sChunk 'append to the field lFileLen = lFileLen - mclChunkSize 'handle the next chunk Wend Close #iFN 'close the file rs.Update 'store recordset onto database Else err.Raise vbObjectError + gclErrFieldNotLongBinary, , "Field '" & .Name & "' is not Long Binary" End If End With 100: End Function




Reply With Quote