Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    If (fso.FileExists("c:\mybmp.bmp")) Then
        Set col = rst1.Fields("image")
        SourceFileNum = FreeFile
        Open ("c:\mybmp.bmp") For Binary As SourceFileNum
        FileLength = LOF(SourceFileNum)
        If FileLength > 50 Then
            NumBlocks = FileLength \ 8192
            LeftOver = FileLength Mod 8192
            ReDim byteData(LeftOver)
            Get SourceFileNum, , byteData()
            col.AppendChunk byteData()
            ReDim byteData(8192)
            For i = 1 To NumBlocks
                Get SourceFileNum, , byteData()
                col.AppendChunk byteData()
           Next
        End If
    End If
    rst1.Update

解决方案 »

  1.   

    ''StrPath为取图片的路径
    'Str 为标号,比如你查找的内容“姓名之类的”
    Public Sub SaveToImage(strPath As String, Str As String, Index As Integer)
    Dim rstab As New ADODB.Recordset
    Dim bytBLOB() As Byte
    Dim intFile As Integer
    Dim strImagePath As StringstrImagePath = Trim$(strPath)
    rstab.Open "select zp,HH from fddbrllb where 标号='" & Str & "'", ConnSrv, adOpenKeyset, adLockOptimistic
    With rstab
       If strImagePath <> "" Then
          intFile = FreeFile
          Open strImagePath For Binary As #intFile
          ReDim bytBLOB(FileLen(strImagePath))
          Get #intFile, , bytBLOB
          Close #1
         If Index = 1 Then
            .Fields("zp").AppendChunk bytBLOB
           Else
            .Fields("HH").AppendChunk bytBLOB
         End If
       End If
    End With
    rstab.Update
    rstab.Close
    Set rstab = Nothing
    End Sub
    程序中可以直接调用, 
    zpPath =dlgDialog .FileName
    call SaveToImage(zpPath, 张三, 1)