Results 1 to 2 of 2

Thread: Blob Handling

  1. #1

    Thread Starter
    New Member Shiny(*)(*)'s Avatar
    Join Date
    Jun 2006
    Location
    Souyh Africa
    Posts
    12

    Blob Handling

    I've got a mysql db on a server. In this db i have photos which i want to "download" to a jpg file format. I use a stream to write the data from a Access db to the mysql db, but when i reverse the process it creates a blank jpg file with no file size or photo in it. Can any one help me with this?

    VB Code:
    1. Sub DBConnectMysql()
    2. Dim StrCnn As String
    3. Dim MySqlHost As String
    4. Dim MySqlDB As String
    5. Dim MySqlUser As String
    6. Dim MySqlPwd As String
    7.  
    8. MySqlHost = "########"
    9. MySqlDB = "#######"
    10. MySqlUser = "########"
    11. MySqlPwd = "########"
    12.  
    13. Set CnnM = New ADODB.Connection
    14.  
    15. StrCnn = "DRIVER={MySQL ODBC 3.51 Driver};" _
    16.     & "SERVER=" & MySqlHost & ";" _
    17.     & "DATABASE=" & MySqlDB & ";" _
    18.     & "UID=" & MySqlUser & ";" _
    19.     & "PWD=" & MySqlPwd & ";" _
    20.     & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    21.  
    22. CnnM.Open StrCnn
    23. Set cmdM = New ADODB.Command
    24. Set cmdM.ActiveConnection = CnnM
    25. End Sub
    26.  
    27.  
    28. If Not IsNull(RSM(3)) Then                
    29. Set cnnConnection = New ADODB.Connection        
    30. PhotoM = RSM(3)                
    31. strStream.Type = adTypeBinary                  
    32. cnnConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _          
    33.    "Data Source=" & ("c:\work\PDE\3dPropMan.mdb") & ";Jet OLEDB:Database Password=3DCla55jul24")                
    34.  
    35. Set rstRecordset = New ADODB.Recordset                  
    36. rstRecordset.Open "Select Photo from Photos where Code = " & RSM(0) & " and ListingCode = '" & RSM(1) & "' and SiteCode = '" & RSM(4) & "'" _        
    37. , cnnConnection, adOpenKeyset, adLockOptimistic                    
    38. Set strStream = New ADODB.Stream          
    39. strStream.Type = adTypeBinary          
    40. strStream.Open          
    41. strStream.Write RSM(3)          
    42. strStream.SaveToFile "c:\work\PDE\Photos\" & RSM(0) & " " & RSM(4) & ".jpg", adSaveCreateOverWrite          
    43.                    
    44. strStream.Close                    
    45. cnnConnection.Close              
    46. End If
    Drive Like You Stole It! But Handle It Like You Own It!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Blob Handling

    Search the forum for GetChunk. There are a lot of examples.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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