在这里有答案:
http://www.lshsoft.net/lshbbs/index.asp?boardid=23从数据库中读取图片(Adodb.Stream)'从数据库中读取图片(Adodb.Stream)
Public Function GetImageFromDB(Rs As ADODB.Recordset, cFieldName As String, strImageFile As String) As Boolean
On Error GoTo ErrExit
If IsNull(Rs.Fields(cFieldName).Value) Then
GoTo ErrExit
Else
Dim stm As ADODB.Stream
Set stm = New ADODB.Stream
stm.Type = adTypeBinary
stm.Open
stm.Write Rs.Fields(cFieldName).Value
stm.SaveToFile strImageFile, adSaveCreateOverWrite
stm.Close
Set stm = Nothing
End If
GetImageFromDB = True
Exit Function
ErrExit:
GetImageFromDB = False
End Function
保存图片到数据库(Adodb.Stream)'保存图片到数据库(Adodb.Stream)
Public Sub SaveImageToDB(Rs As ADODB.Recordset, cFieldName As String, strImageFile As String)
Dim stm As ADODB.Stream
Set stm = New ADODB.Stream
stm.Type = adTypeBinary
stm.Open
stm.LoadFromFile strImageFile
Rs.Fields(cFieldName).Value = stm.Read
Rs.Update
stm.Close
Set stm = Nothing
End Sub