主题:数据库写图片
Dim myrs As Recordset
Dim mydb As Database
Private Sub Command1_Click() ‘添加
Set mydb = OpenDatabase("c:\d.mdb")
我建好的mdb数据表名pic,字段名ps,类型byte
Set myrs = mydb.OpenRecordset("pic")
Dim PBag As New PropertyBag
Dim B() As Byte
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
PBag.WriteProperty "pic", Picture1.Picture
'读取Picture1.Picture 图片并写到 Pbag 容器中
B = PBag.Contents '获取容器Byte 到 B() 数组
myrs.AddNew
myrs.Fields("ps") = B'这里显示数据类型错误,请大家帮个忙解决下呀
myrs.Update
'关闭
myrs.Close
Set myrs = Nothing
End Sub
Dim mydb As Database
Private Sub Command1_Click() ‘添加
Set mydb = OpenDatabase("c:\d.mdb")
我建好的mdb数据表名pic,字段名ps,类型byte
Set myrs = mydb.OpenRecordset("pic")
Dim PBag As New PropertyBag
Dim B() As Byte
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
PBag.WriteProperty "pic", Picture1.Picture
'读取Picture1.Picture 图片并写到 Pbag 容器中
B = PBag.Contents '获取容器Byte 到 B() 数组
myrs.AddNew
myrs.Fields("ps") = B'这里显示数据类型错误,请大家帮个忙解决下呀
myrs.Update
'关闭
myrs.Close
Set myrs = Nothing
End Sub