Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Posts
    78

    Question Unanswered: BLOB retrieve using VB messes up data in files

    I am using following code to retrieve a file from database from a BLOB column. I am able to retrieve the file and save in c:\temp directory, but VBA adds some junk characters at start of file making some files like jpg images un-readable. Can anyone tell whats wrong with the code or or do I need to use some other driver for connection etc...

    Code:
    Sub Test()
        Dim ProdConnectString
        Dim conn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim myStreaM As New ADODB.Stream
        'String used for connecting to DB
        ProdConnectString = "provider=msdaora.1;user id=user;password=psd;data source = ds;option=1+2+8+32+2048+16384"
        Set conn = New ADODB.Connection
        conn.ConnectionString = ProdConnectString
        conn.CursorLocation = adUseClient
        conn.Open
        rs.Open "select file_data from TABLE where NAME ='ABCD.txt'", conn
        myStreaM.Open
        myStreaM.WriteText rs!file_data
        myStreaM.SaveToFile "c:\temp\XYZ.txt" , adSaveCreateOverWrite 
        myStreaM.Close
        rs.Close
        conn.Close
    End Sub
    File example (first 2 characters are junk):
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    Thanks.

    ~BS

  2. #2
    Join Date
    Dec 2004
    Posts
    78

Posting Permissions

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