如何把图片存入数据库(SQL)中,并从中读出显示出来

解决方案 »

  1.   

    Private Sub ImportBLOB()Dim rs As New ADODB.Recordset
    Dim stm As ADODB.StreamSet stm = New ADODB.Stream' Skip any table not found errors
    On Error Resume Next
    'cn.Execute "drop table BinaryObject"On Error GoTo 0
    'Create the BinaryObject tablers.Open "Select * from a where 1=2", cn, adOpenKeyset, adLockOptimistic
    'Read the binary files from disk
    stm.Type = adTypeBinary
    stm.Open
    stm.LoadFromFile App.Path & "\1.bmp"rs.AddNew
    rs!c = App.Path & "\1.bmp"
    rs!r = stm.Read'Insert the binary object in the table
    rs.Updaters.Close
    stm.CloseSet rs = Nothing
    Set stm = Nothing
    End Sub'显示图片
    Private Sub DisplayBLOB()Dim rs As New ADODB.Recordset' Select the only image in the table
    rs.Open "Select * from a ", cn, adOpenForwardOnlySet imgBinaryData.DataSource = rs   'imgBinaryData为图片框imgBinaryData.DataField = rs!r.Namers.Close
    Set rs = Nothing
    End Sub
      

  2.   

    http://blog.csdn.net/online/archive/2004/08/19/78622.aspx
      

  3.   

    http://community.csdn.net/Expert/topic/3419/3419541.xml?temp=.8924219