'将图片存入数据库
'首先将文件读入一字节数组
Dim bit() As Byte
Open "C:\WINDOWS\安装程序.bmp" For Binary As #1
ReDim bit(LOF(1)) As Byte
Get 1, 1, bit
Close 1
'然后将字节数组的内容写入数据库即可
Dim cnn As New ADODB.Connection, rst As New ADODB.Recordset
cnn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Northwind;Data Source=rdm"
rst.Open "T1", cnn, adOpenKeyset, adLockOptimistic
rst.AddNew
rst("F1").AppendChunk bit
rst.Update
'
' '将数据库中的图片读出
' '首先将数据库中的内容读到一字节数组
' Dim bit1() As Byte
' bit1 = rst("F1").GetChunk(rst("F1").ActualSize)
' '然后将字节数组的内容拼装成文件即可
' Open "c:\1.bmp" For Binary As #1
' Put 1, 1, bit1
' Close 1
' Me.Picture = LoadPicture("c:\1.bmp")