<p>I have a table in an access table which contains Product entries,  one of the columns has a jpg image stored as an OLE Object.  I am trying to import this table to MySQL but nothing seems to work.  I have tried the MySQL migration tool but that has a known issue with Access and OLE Objects.  (The issue being it doesnt work and leaves the fields blank)  I also tried the suggestion on <a href="http://www.plus2net.com/sql_tutorial/access_to_mysql.php" rel="nofollow noreferrer">this site</a>
and while the data is imported it seems as though the image is getting corrupted in the transfer.  When i try to preview the image i just get a binary view, if i save it on disk as a jpg image and try to open it i get an error stating the image is corrupt.</p>

<p>The images in Access are fine and can be previewed.  Access is storing the data as an OLE Object and when i import it to MySql it is saved in a MediumBlob field.</p>

<p>Has anyone had this issue before and how did they resolve it ?</p>

[{'answer_id': 41617, 'author': 'DAC', 'author_id': 1111, 'author_profile': 'https://Stackoverflow.com/users/1111', 'pm_score': 1, 'selected': False, 'text': '<p>As far as I remember, the Microsoft "<a href="http://www.microsoft.com/downloads/details.aspx?familyid=D842F8B4-C914-4AC7-B2F3-D25FFF4E24FB&amp;displaylang=en" rel="nofollow noreferrer">SQL Server Migration Assistant for Access</a>" will properly migrate OLE Images, but this is only for Access->SQLServer. However, what you can do is use this to migrate to SQLServer Express (free download) and then migrate from SQLServer to MySQL.</p>\n'}, {'answer_id': 41985, 'author': 'SecretDeveloper', 'author_id': 2720, 'author_profile': 'https://Stackoverflow.com/users/2720', 'pm_score': 3, 'selected': True, 'text': '<p>Ok so in the interests of airing my dirty code in public here what i came up with.<br>\nNote :  this is a hack designed to be used once and then thrown away.</p>\n\n<p>This Method takes in a datarowview containing 1 row of data from the access table.  The Images are wrapped in OLE serialization,  im not entirely familiar with how this works but its how Microsoft apps allow any object to be embedded into something else. (eg images into Excel Cells).  I needed to remove the serialization junk around the image so i loaded the entire field as a Byte array and searched through it for 3 concurrent entries (FF D8 FF) which represent the beginning of the image data within the field.</p>\n\n<pre><code>    Private Function GetImageFromRow(ByRef row As DataRowView, ByVal columnName As String) As Bitmap\n    Dim oImage As Bitmap = New Bitmap("c:\\default.jpg")\n    Try\n        If Not IsDBNull(row(columnName)) Then\n            If row(columnName) IsNot Nothing Then\n                Dim mStream As New System.IO.MemoryStream(CType(row(columnName), Byte()))\n                If mStream.Length &gt; 0 Then\n\n                    Dim b(Convert.ToInt32(mStream.Length - 1)) As Byte\n                    mStream.Read(b, 0, Convert.ToInt32(mStream.Length - 1))\n\n                    Dim position As Integer = 0\n\n                    For index As Integer = 0 To b.Length - 3\n                        If b(index) = &amp;HFF And b(index + 1) = &amp;HD8 And b(index + 2) = &amp;HFF Then\n                            position = index\n                            Exit For\n                        End If\n                    Next\n\n                    If position &gt; 0 Then\n                        Dim jpgStream As New System.IO.MemoryStream(b, position, b.Length - position)\n                        oImage = New Bitmap(jpgStream)\n                    End If\n                End If\n            End If\n        End If\n    Catch ex As Exception\n        Throw New ApplicationException(ex.Message, ex)\n    End Try\n    Return oImage\nEnd Function\n</code></pre>\n\n<p>Then its a matter of pulling out this data into a bitmap.  So for each row in the access table i extract the bitmap and then update the corresponding MySQL entry.<br>\nIt worked fine but im guessing i could have removed the serialisation stuff in a better way, perhaps theres an API to do it.</p>\n'}, {'answer_id': 10059187, 'author': 'ash', 'author_id': 17708, 'author_profile': 'https://Stackoverflow.com/users/17708', 'pm_score': 0, 'selected': False, 'text': '<p>There\'s also <a href="https://github.com/shamrin/olefield" rel="nofollow">olefield</a> - Python module to extract data out of OLE object fields in Access. I successfully extracted BMP files with it. It could probably work with jpeg images, but I haven\'t tried it.</p>\n'}]
['https://Stackoverflow.com/questions/41594', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2720/']