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:
Sub DBConnectMysql() Dim StrCnn As String Dim MySqlHost As String Dim MySqlDB As String Dim MySqlUser As String Dim MySqlPwd As String MySqlHost = "########" MySqlDB = "#######" MySqlUser = "########" MySqlPwd = "########" Set CnnM = New ADODB.Connection StrCnn = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=" & MySqlHost & ";" _ & "DATABASE=" & MySqlDB & ";" _ & "UID=" & MySqlUser & ";" _ & "PWD=" & MySqlPwd & ";" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384 CnnM.Open StrCnn Set cmdM = New ADODB.Command Set cmdM.ActiveConnection = CnnM End Sub If Not IsNull(RSM(3)) Then Set cnnConnection = New ADODB.Connection PhotoM = RSM(3) strStream.Type = adTypeBinary cnnConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & ("c:\work\PDE\3dPropMan.mdb") & ";Jet OLEDB:Database Password=3DCla55jul24") Set rstRecordset = New ADODB.Recordset rstRecordset.Open "Select Photo from Photos where Code = " & RSM(0) & " and ListingCode = '" & RSM(1) & "' and SiteCode = '" & RSM(4) & "'" _ , cnnConnection, adOpenKeyset, adLockOptimistic Set strStream = New ADODB.Stream strStream.Type = adTypeBinary strStream.Open strStream.Write RSM(3) strStream.SaveToFile "c:\work\PDE\Photos\" & RSM(0) & " " & RSM(4) & ".jpg", adSaveCreateOverWrite strStream.Close cnnConnection.Close End If





Reply With Quote