vb怎么把图片加入到数据库里面

Private Sub Command3_Click()
Dim conn As New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/1.mdb;Persist Security Info=False"
conn.Execute "create table a (b longbinary)"
End Sub

Private Sub Command4_Click()
    Set b = New ADODB.Recordset
    Set c = New ADODB.Stream
       
       
        c.Mode = adModeReadWrite

    c.Type = adTypeBinary
    c.Open
    c.LoadFromFile "c:/1.bmp"
   
    b.Open "select * from a", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/1.mdb;Persist Security Info=False", adOpenDynamic, adLockOptimistic
    b.AddNew
   
    b.Fields.Item(0).Value = c.Read()
   
   
    b.Update
   
    b.Close
    Set b = New ADODB.Recordset
    b.Open "select * from a", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/1.mdb;Persist Security Info=False", adOpenKeyset, adLockOptimistic
    MsgBox b.RecordCount
   
    b.MoveLast
   
    c.Write (b.Fields.Item(0).Value)
   
    c.SaveToFile "c:/aa.bmp", adSaveCreateOverWrite
   
    Picture1.Picture = LoadPicture("c:/aa.bmp")
End Sub

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页