Private Sub readfile()
Dim iStm As ADODB.Stream
Dim iRe As ADODB.Recordset
iConcstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\yuangong.mdb" '得到最新添加的纪录
Set iConc = New ADODB.Connection
iConc.Open iConcstr
Set iRe = New ADODB.Recordset '打开表
iRe.Open "select * from yuangong_info where 职工编号='" & Trim(Form1.Text1) & "'", iConc, adOpenKeyset, adLockReadOnly
If iRe.EOF = True Then
MsgBox "该员工暂时无照片"
Else
Set iStm = New ADODB.Stream '保存到文件
With iStm
.Mode = adModeReadWrite
.Type = adTypeBinary
.Open
.Write iRe("photo")
.SaveToFile App.Path & "\4.jpg" '这里注意了,如果当前目录下存在test1.jpg,会报一个文件写入失败的错误.
End With
Form1.Picture1.Picture = LoadPicture(App.Path & "\4.jpg")
iRe.Close '关闭对象
iStm.Close
Kill App.Path & "\4.jpg"
End If
End Sub
红色部分是我在原来代码基础上,来处理数据库中的“photo”为空的代码,可是怎么不起作用。请问,当读取空“photo”时如何处理?
[求助]数据库中无图片怎么处理?