1,451
社区成员
发帖
与我相关
我的任务
分享
If Dir(App.Path & "\test1.jpg") <> "" Then
Kill App.Path & "\test1.jpg"
End If
Sub s_ReadFile()
Dim iStm As ADODB.Stream
Dim iRe As ADODB.Recordset
'打开表
Set iRe = New ADODB.Recordset
'得到最新添加的纪录
iRe.Open "select top 1 * from img order by id desc", iConc, adOpenKeyset, adLockReadOnly
'保存到文件
Set iStm = New ADODB.Stream
With iStm
.Mode = adModeReadWrite
.Type = adTypeBinary
.Open
.Write iRe("photo")
'这里注意了,如果当前目录下存在test1.jpg,会报一个文件写入失败的错误.
.SaveToFile App.Path & "\test1.jpg"
End With
Image1.Picture = LoadPicture(App.Path & "\test1.jpg") '***************************
'关闭对象
iRe.Close
iStm.Close
End Sub
Private Sub Command2_Click()
Dim f1 As Single
Dim strb() As Byte
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Binary As #1
f1 = LOF(1)
ReDim strb(f1)
Get #1, , strb
Adodc1.Recordset.Fields("photo").AppendChunk strb
Close #1
Image1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub