我就是这样用的
Public Function read_image(read_write As String, ksql As String, source_file_name As String, Optional export_path As String, Optional export_file_name As String, Optional show_photo As PictureBox) As Boolean
On Error GoTo err_msg
dim conn As New Connection
Dim rs As New Recordset
Dim mstream As New Stream
'打开数据库
If kpublic.conn_string = False Then
read_image = False
Exit Function
End If
If db_string <> "" Then
conn.ConnectionTimeout = 39
conn.Open db_string
End If
rs.Open ksql, conn, adOpenKeyset, adLockOptimistic
If read_write = "write" Then
If Dir(source_file_name) = "" Then
kcheck.sys_message "发现所指定的图片文件不存在!!read_image", "waring !!"
read_image = False
End If
If Dir(export_path, vbDirectory) = "" Then '如输出的路径不存在则新建
MkDir export_path '新增文件夹
End If
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rs.Fields(0).Value
If mstream.Size > 1 Then 'Size >0 表明存放有图片
mstream.SaveToFile export_path & "\" & export_file_name, adSaveCreateOverWrite
If Dir(export_path & "\" & export_file_name) <> "" Then
show_photo.Picture = LoadPicture(export_path & "\" & export_file_name)
End If
End If
End If
rs.Update
rs.Close
conn.Close
read_image = True
Exit Function
err_msg:
kcheck.sys_message "系统在读取图片资料时出现未知错误!!read_image", "waring !!"
read_image = False
End Function