Results 1 to 1 of 1

Thread: BLOB data ADO Streams in VBA [Solved]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Location
    Cambridge,MA
    Posts
    20

    BLOB data ADO Streams in VBA [Solved]

    Hello,

    I'm having trouble with the following code, and am wondering if there is a problem with what i'm trying to do. I'm trying to read blob data which contains a bmp file into a local file so I can open it.

    This isn't necessarily specific to VBA, but I'm working in VBA so I'm posting it here.

    VB Code:
    1. Dim mystream As ADODB.Stream
    2.     Dim rst As ADODB.Recordset
    3.     Dim Cnxn As ADODB.Connection            ' connection to db
    4.     Dim strCnxn As String                   ' connection arguments
    5.     Dim strSQL As String                    ' query var
    6.    
    7.     Set Cnxn = New ADODB.Connection
    8.     Set rst = New ADODB.Recordset
    9.     strCnxn = ThisWorkbook.strCnxn
    10.     Cnxn.CursorLocation = adUseClient
    11.  
    12.     Cnxn.Open strCnxn
    13.     Set mystream = New ADODB.Stream
    14.     mystream.Type = adTypeBinary
    15.    
    16.     rst.Open "SELECT * FROM bay_pictures limit 1", Cnxn
    17.     mystream.Open
    18.     mystream.Write rst.Fields("pic_data").Value
    19.    
    20.     mystream.SaveToFile "c:\" & rst!pic_name, adSaveCreateOverWrite
    21.     mystream.Close

    The code generates and E_FAIL -2147467259 (800040005) on the line where I call
    VB Code:
    1. mystream.Write rst.Fields("pic_data").Value

    Any suggestions?
    Last edited by recarv; Jan 16th, 2005 at 08:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width