VB怎么按条件读取ACCESS图片 + 数据,
最好能够显示在MSHFlexGrid上,先谢谢大家了!

解决方案 »

  1.   

    按条件读取
    iRe.Open "select  * from my_table id ='" & text1 & "'", iConc, adOpenKeyset, adLockReadOnly
      

  2.   


    那图片是OLE二进制的,不用转换回来吗?
      

  3.   


    你这个帖子不已经解决了吗?
    http://topic.csdn.net/u/20101007/10/56f32c26-5660-4811-b036-4e6a80d855d2.html
      

  4.   

    我不会连起来,我要么只能读数据,
    要么只能读图片,图片只能读到Image,也不能按条件读图片,来来去去就只能读一张!
    拜托了,帮下忙,谢谢!
      

  5.   

    Dim cnnImage As New ADODB.Connection
    Dim rsImage As New ADODB.Recordset
    Dim strSql As StringDim Chunk() As Byte
    Dim lngLengh As Long
    Dim intChunks As Integer
    Dim intFragment As Integer
    Const ChunkSize = 1000
    Const lngDataFile = 1
        
        Strpassword = Form4.password
    strFileName = Form4.fun_GetFileName()
        
        rsImage.LockType = adLockOptimistic
        rsImage.CursorType = adOpenKeyset
        cnnImage.Provider = "Microsoft.Jet.OLEDB.4.0"
        strSql = strFileName
        cnnImage.Open strSql
        strSql = "Select * From data"
        rsImage.Open strSql, cnnImage
        If (rsImage.BOF = True) And (rsImage.EOF = True) Then Exit Sub
        
      
        Open "pictemp" For Binary Access Write As lngDataFile
            lngLengh = rsImage!photo.ActualSize
            intChunks = lngLengh \ ChunkSize
            intFragment = lngLengh Mod ChunkSize
            ReDim Chunk(intFragment)
            Chunk() = rsImage!photo.GetChunk(intFragment)
            Put lngDataFile, , Chunk()
            For I = 1 To intChunks
               ReDim Buffer(ChunkSize)
               Chunk() = rsImage!photo.GetChunk(ChunkSize)
              
               Put lngDataFile, , Chunk()
            Next I
        Close lngDataFile
        FileName = "pictemp"
        Image1.Picture = LoadPicture(FileName)
    End Sub这个只能读到Image,不能按条件!
      

  6.   

        Dim cnnImage As New ADODB.Connection
        Dim rsImage As New ADODB.Recordset
        Dim strSql As String
        
        Dim Chunk() As Byte
        Dim lngLengh As Long
        Dim intChunks As Integer
        Dim intFragment As Integer
        Const ChunkSize = 1000
        Const lngDataFile = 1
        
        Strpassword = Form4.password
        strFileName = Form4.fun_GetFileName()
        
        rsImage.LockType = adLockOptimistic
        rsImage.CursorType = adOpenKeyset
        cnnImage.Provider = "Microsoft.Jet.OLEDB.4.0"
        strSql = strFileName
        cnnImage.Open strSql
        strSql = "Select * From data where id = '" & text1 & "'"
        rsImage.Open strSql, cnnImage
        If (rsImage.BOF = True) And (rsImage.EOF = True) Then Exit Sub
        
        
        Open "pictemp" For Binary Access Write As lngDataFile
        lngLengh = rsImage!photo.ActualSize
        intChunks = lngLengh \ ChunkSize
        intFragment = lngLengh Mod ChunkSize
        ReDim Chunk(intFragment)
        Chunk() = rsImage!photo.GetChunk(intFragment)
        Put lngDataFile, , Chunk()
        
        For I = 1 To intChunks
            ReDim Buffer(ChunkSize)
            Chunk() = rsImage!photo.GetChunk(ChunkSize)
            
            Put lngDataFile, , Chunk()
        Next I
        
        Close lngDataFile
        FileName = "pictemp"
        Image1.Picture = LoadPicture(FileName)
      

  7.   

    行了,非常感谢,
    那如果要加上数据一起查到MSHFlexGrid,是不是要建立两个查询啊?
    这个Pictemp临时文件在桌面,能不能改到目录下啊?
    再帮一下忙,你的帮忙真如雪中送炭!
      

  8.   

    我有一套完整的ACCESS存储图片的程序,需要的留个邮箱。
      

  9.   

    Dim cnnImage As New ADODB.Connection
      Dim rsImage As New ADODB.Recordset
      Dim strSql As String
        
      Dim Chunk() As Byte
      Dim lngLengh As Long
      Dim intChunks As Integer
      Dim intFragment As Integer
      Const ChunkSize = 1000
      Const lngDataFile = 1
        
      Strpassword = Form4.password
      strFileName = Form4.fun_GetFileName()
        
      rsImage.LockType = adLockOptimistic
      rsImage.CursorType = adOpenKeyset
      cnnImage.Provider = "Microsoft.Jet.OLEDB.4.0"
      strSql = strFileName
      cnnImage.Open strSql
      strSql = "Select * From data where id = '" & text1 & "'"
      rsImage.Open strSql, cnnImage
      If (rsImage.BOF = True) And (rsImage.EOF = True) Then Exit Sub
        
       FileName = App.Path & "\pictemp"
       
      Open FileName For Binary Access Write As lngDataFile
      lngLengh = rsImage!photo.ActualSize
      intChunks = lngLengh \ ChunkSize
      intFragment = lngLengh Mod ChunkSize
      ReDim Chunk(intFragment)
      Chunk() = rsImage!photo.GetChunk(intFragment)
      Put lngDataFile, , Chunk()
        
      For I = 1 To intChunks
      ReDim Buffer(ChunkSize)
      Chunk() = rsImage!photo.GetChunk(ChunkSize)
        
      Put lngDataFile, , Chunk()
      Next I
        
      Close lngDataFile
      
      Image1.Picture = LoadPicture(FileName)