请看下面的代码有什么问题? 
Image1.Picture = Nothing
            If rec("照片").ActualSize > 50 Then
                bit1 = rec.Fields("照片").GetChunk(rec("照片").ActualSize)
                '然后将字节数组的内容拼装成文件即可
                Open "c:\1.bmp" For Binary As #1
                Put 1, 1, bit1
                Close 1
                Image1.Picture = LoadPicture("c:\1.bmp")
                Image1.Stretch = True
               ' Picture1.Picture = LoadPicture("c:\1.bmp")
                Kill ("c:\1.bmp")
            End If
执行到Image1.Picture = LoadPicture("c:\1.bmp")时,系统报错“无效图片”,请大家帮忙,

解决方案 »

  1.   

    直接绑定Picture控件到rec("照片")上
      

  2.   

    Set Picture1.DataSource = rec
    Picture1.DataField = "照片" 'rec("照片").name
      

  3.   

    我现在发现图片存进去也有问题
        Open "c:\015.JPG" For Binary Access Read As lngDataFile
        lngLengh = LOF(lngDataFile)
        If lngLengh = 0 Then Close lngDataFile: Exit Sub
        intChunks = lngLengh \ ChunkSize
        intFragment = lngLengh Mod ChunkSize
        
        'OpenData 打开数据库
        Dim i As Integer
        Dim rs As New ADODB.Recordset
        Dim strQ  As String
        
        If rs.State = adStateOpen Then rs.Close
        
        strQ = "select * from scanimage"
        rs.Open strQ, localcon1, adOpenStatic, adLockOptimistic
    '    Set rs = localcon1.Execute("select * from scanimage where id=1", adOpenKeyset, adLockOptimistic)'    On Error Resume Next
        
        rs.AddNew
        
        ReDim Chunk(intFragment)
        Get lngDataFile, , Chunk()
        rs.Fields("imagename").AppendChunk Chunk()
        ReDim Chunk(ChunkSize)
        
        For i = 1 To intChunks
            Get lngDataFile, , Chunk()
            rs.Fields("imagename").AppendChunk Chunk()
        Next i
        
        rs.Update
        rs.Close
        Close lngDataFile
    哪里有问题?
      

  4.   

    一个存图象到数据库然后读出的例子!
    Private Sub ImportBLOB(cn As ADODB.Connection)
        
        Dim rs As New ADODB.Recordset
        Dim stm As ADODB.Stream
        
        Set 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 table
        cn.Execute "create table BinaryObject " & _
                     "(blob_id int IDENTITY(1,1), " & _
                      "blob_filename varchar(256), " & _
                      "blob_object image)"
                    
        rs.Open "Select * from BinaryObject where 1=2", cn, adOpenKeyset, adLockOptimistic
        'Read the binary files from disk
        stm.Type = adTypeBinary
        stm.Open
        stm.LoadFromFile App.Path & "\BLOBsample.jpg"
        
        rs.AddNew
        rs!blob_filename = App.Path & "\BLOBsample.jpg"
        rs!blob_object = stm.Read
        
        'Insert the binary object in the table
        rs.Update
        
        rs.Close
        stm.Close
        
        Set rs = Nothing
        Set stm = Nothing
        
    End Sub
    Private Sub DisplayBLOB(cn As ADODB.Connection)    Dim rs As New ADODB.Recordset
        
        ' Select the only image in the table
        rs.Open "Select * from BinaryObject where blob_id = 1", cn
        
        ' Set the DataSource to the recordset
        Set imgBinaryData.DataSource = rs
        'Set the DataField to the BLOB field
        imgBinaryData.DataField = rs!blob_object.Name
        
        'Release the recordset
        rs.Close
        Set rs = NothingEnd Sub
      

  5.   

    用直接绑定Picture控件到rec("照片")上的方法,好是好,但如图片过大没有滚动条啊,而且我想用webbrowser控件显示图片
      

  6.   

    dim bit1() as byte          
            bit1() = rs("照片")
            Open "1.bmp" For Binary As #1
            Put 1, , bb()
            Close 1
            Image1.Picture = LoadPicture("1.bmp")
            Kill "t2.bmp"
      

  7.   

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

  8.   

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

  9.   

    hsn1982(我 爱 猫 猫) :你的办法看来还不错!写入数据库有没有好办法?
      

  10.   

    New ADODB.Stream须要加什么引用之类?