如何在SQL Server或Access数据库中存入图片?并用VB调用出来显示?不胜感谢!

解决方案 »

  1.   

    看看这个帖子就全解决了
    http://expert.csdn.net/Expert/topic/2487/2487920.xml?temp=.6590387
      

  2.   


    微软的答案:VB6向SQL SERVER存入图象:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;258038VB.NET向SQL SERVER存入图象:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;308042
      

  3.   

    将图片写入数据库并显示
    http://www.dapha.net/down/list.asp?id=1826
      

  4.   

    给一个vb的例子给你
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim stm As ADODB.StreamPrivate Sub SavePictureToDB(cn As ADODB.Connection)
    '将BMP图片存入数据库
    On Error GoTo EH
        Set stm = New ADODB.Stream
        rs.Open "select ImagePath,ImageValue from tbl_Image", cn, adOpenKeyset, adLockOptimistic
        CommonDialog1.ShowOpen
        Text1.Text = CommonDialog1.FileName
        
        With stm
             .Type = adTypeBinary
             .Open
             .LoadFromFile CommonDialog1.FileName
        End With
        With rs
             .AddNew
             .Fields("ImagePath") = Text1.Text
             .Fields("ImageValue") = stm.Read
             .Update
        End With
        rs.Close
        Set rs = Nothing
    Exit Sub
    EH: MsgBox Err.Description, vbInformation, "Error"
    End Sub
    Private Sub LoadPictureFromDB(cn As ADODB.Connection)
    '载数据库中读出BMP图片
    On Error GoTo EH
        Dim strTemp As String
        Set stm = New ADODB.Stream
        strTemp = "c:\temp.tmp" '临时文件,用来保存读出的图片
        rs.Open "select ImagePath,ImageValue  from tbl_image", cn, , , adCmdText
        With stm
            .Type = adTypeBinary
            .Open
            .Write rs("ImageValue")
            .SaveToFile strTemp, adSaveCreateOverWrite
            .Close
        End With
        Image1.Picture = LoadPicture(strTemp)
        Set stm = Nothing
        rs.Close
        Set rs = Nothing
    Exit Sub
    EH: MsgBox Err.Description, vbInformation, "Error"
    End Sub