如何将数据库中的图片(二进制),读出并显示在界面的Image控件?[VB6.0]
如题!注:数据库中并不是保存的图片路径,而是采用的二进制保存到数据库中的,望各位最好能给出参考代码,谢谢!...
如题!注:数据库中并不是保存的图片路径,而是采用的二进制保存到数据库中的,望各位最好能给出参考代码,谢谢!
展开
1个回答
展开全部
Public strImgN As String '图片路径 把picture或者image存储成图片
Public BImg() As Byte
'#########写入数据库#######
Public Sub Image() '
On Error Resume Next
Dim IntNum As Integer
IntNum = FreeFile
Open strImgN For Binary As #IntNum
ReDim BImg(FileLen(strImgN))
Get #IntNum, , BImg
Close #1
End Sub
Public Sub WriteDataFromControlsEdit()
Call Image
adoview.Fields("picblob").AppendChunk BImg
adoview.Update
End Sub
'#################装置图片#################
Public Sub LoadImage()
On Error Resume Next
Dim ImgS As Long
Dim OS As Long
Dim TmpPic As String
Const conCS = 100
TmpPic = App.Path & "\tmpPic.bmp"
If Len(Dir(TmpPic)) > 0 Then
Kill TmpPic
End If
Dim F As Integer
F = FreeFile
Open App.Path & "\tmpPic.bmp" For Binary As #F
ImgS = adoview.Fields("picblob").ActualSize
Do While OS < ImgS
BImg() = adoview _
("picblob").GetChunk(conCS)
Put #F, , BImg
OS = OS + conCS
Loop
Close #F
If infomode = True And findmode = False Then
frmPersonalInfo.imgpic.Picture = LoadPicture(App.Path & "\tmpPic.bmp")
Kill App.Path & "\tmpPic.bmp"
ElseIf findmode = True And infomode = False Then
frmFind.imgpic.Picture = LoadPicture(App.Path & "\tmpPic.bmp")
Kill App.Path & "\tmpPic.bmp"
End If
End Sub
省略了一部分数据库的内容 不知道你能不能领悟
Public BImg() As Byte
'#########写入数据库#######
Public Sub Image() '
On Error Resume Next
Dim IntNum As Integer
IntNum = FreeFile
Open strImgN For Binary As #IntNum
ReDim BImg(FileLen(strImgN))
Get #IntNum, , BImg
Close #1
End Sub
Public Sub WriteDataFromControlsEdit()
Call Image
adoview.Fields("picblob").AppendChunk BImg
adoview.Update
End Sub
'#################装置图片#################
Public Sub LoadImage()
On Error Resume Next
Dim ImgS As Long
Dim OS As Long
Dim TmpPic As String
Const conCS = 100
TmpPic = App.Path & "\tmpPic.bmp"
If Len(Dir(TmpPic)) > 0 Then
Kill TmpPic
End If
Dim F As Integer
F = FreeFile
Open App.Path & "\tmpPic.bmp" For Binary As #F
ImgS = adoview.Fields("picblob").ActualSize
Do While OS < ImgS
BImg() = adoview _
("picblob").GetChunk(conCS)
Put #F, , BImg
OS = OS + conCS
Loop
Close #F
If infomode = True And findmode = False Then
frmPersonalInfo.imgpic.Picture = LoadPicture(App.Path & "\tmpPic.bmp")
Kill App.Path & "\tmpPic.bmp"
ElseIf findmode = True And infomode = False Then
frmFind.imgpic.Picture = LoadPicture(App.Path & "\tmpPic.bmp")
Kill App.Path & "\tmpPic.bmp"
End If
End Sub
省略了一部分数据库的内容 不知道你能不能领悟
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
TableDI
2024-07-18 广告
2024-07-18 广告
在上海悉息信息科技有限公司,我们深知Excel在数据处理中的重要作用。在Excel中引用不同工作表(sheet)的数据是常见的操作,这有助于整合和分析跨多个工作表的信息。通过在工作表名称前加上感叹号“!”,您可以轻松地引用其他工作表中的数据...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询