StmPic.Close
Exit Sub
err:
MsgBox err.Description
End Sub
-----------------------------------------
'读出图片,并显示
Private Sub Command2_Click()
Dim StmPic As ADODB.Stream
' On Error GoTo err
'读取显示数据库中id为111的图像
Set rs = conn.Execute("select img from planemsg where id='111'")
StrPicTemp = "c:\temp.jpeg"
Set StmPic = New ADODB.Stream
With StmPic
.Type = adTypeBinary
.Open
.Write rs.Fields("img") '写入数据库中的数据至Stream中
.SaveToFile StrPicTemp, adSaveCreateOverWrite '将Stream中数据写入临时文件中
.Close
End With
Picture2.Picture = LoadPicture(StrPicTemp) '用Picture控件显示图像
Exit Sub
err:
MsgBox err.Description
End Sub