3个回答
展开全部
我使用过,我一般是这么处理的,如下(我用的vb,你可以转变成access里的代码):
图片是可以放到数据库里面的,以ACCESS为例子,要使用OLE数据类型,
然后把图片转化为长二进制数据存入,读取的时候可以生成系统隐藏的图
片然后在图片控件中显示
Dim cc() As Byte
Dim i
Dim t
Private Sub Command1_Click()
CommonDialog1.Filter = "JPG图片(*.BMP)|*.BMP"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
strname = CommonDialog1.FileName
Open strname For Binary As #1
ReDim cc(LOF(1) - 1)
t = cc(LOF(1) - 1) '在读取二进制时,如果是用文件操作那么涉及到到底从文件中取多少字节的问题,所以字节数组要指定大小
Get #1, , cc
Close
Else
MsgBox "没有选中图片"
End If
End Sub
Private Sub Command2_Click()
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("id") = i
Adodc1.Recordset.Fields("qq") = cc
i = i + 1
Adodc1.Recordset.Update
Adodc1.Refresh
End Sub
Private Sub Command3_Click()
Adodc1.Refresh
Dim P() As Byte
Adodc1.RecordSource = "select qq from 表一 where id='" & Text1.Text & "'"
P = Adodc1.Recordset.Fields("qq") '当把一组二进制数据赋值给一个二进制数组时就不用指定数组的大小了,因为是全部赋值
Open App.Path & "\oo.bmp" For Binary As #1
Put #1, , P
Close
End Sub
Private Sub Command4_Click()
Open App.Path & "\oo.bmp" For Binary As #1
Put #1, , cc
Close
End Sub
Private Sub Form_Load()
i = 1
End Sub
图片是可以放到数据库里面的,以ACCESS为例子,要使用OLE数据类型,
然后把图片转化为长二进制数据存入,读取的时候可以生成系统隐藏的图
片然后在图片控件中显示
Dim cc() As Byte
Dim i
Dim t
Private Sub Command1_Click()
CommonDialog1.Filter = "JPG图片(*.BMP)|*.BMP"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
strname = CommonDialog1.FileName
Open strname For Binary As #1
ReDim cc(LOF(1) - 1)
t = cc(LOF(1) - 1) '在读取二进制时,如果是用文件操作那么涉及到到底从文件中取多少字节的问题,所以字节数组要指定大小
Get #1, , cc
Close
Else
MsgBox "没有选中图片"
End If
End Sub
Private Sub Command2_Click()
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("id") = i
Adodc1.Recordset.Fields("qq") = cc
i = i + 1
Adodc1.Recordset.Update
Adodc1.Refresh
End Sub
Private Sub Command3_Click()
Adodc1.Refresh
Dim P() As Byte
Adodc1.RecordSource = "select qq from 表一 where id='" & Text1.Text & "'"
P = Adodc1.Recordset.Fields("qq") '当把一组二进制数据赋值给一个二进制数组时就不用指定数组的大小了,因为是全部赋值
Open App.Path & "\oo.bmp" For Binary As #1
Put #1, , P
Close
End Sub
Private Sub Command4_Click()
Open App.Path & "\oo.bmp" For Binary As #1
Put #1, , cc
Close
End Sub
Private Sub Form_Load()
i = 1
End Sub
参考资料: http://hi.baidu.com/control%5Fworld/blog/item/3bce2d6dc1d58bfe43169430.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
存放图片路径比较简单
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询