Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok so in the interests of airing my dirty code in public here what i came up with.<br> Note : this is a hack designed to be used once and then thrown away.</p> <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> <pre><code> Private Function GetImageFromRow(ByRef row As DataRowView, ByVal columnName As String) As Bitmap Dim oImage As Bitmap = New Bitmap("c:\default.jpg") Try If Not IsDBNull(row(columnName)) Then If row(columnName) IsNot Nothing Then Dim mStream As New System.IO.MemoryStream(CType(row(columnName), Byte())) If mStream.Length &gt; 0 Then Dim b(Convert.ToInt32(mStream.Length - 1)) As Byte mStream.Read(b, 0, Convert.ToInt32(mStream.Length - 1)) Dim position As Integer = 0 For index As Integer = 0 To b.Length - 3 If b(index) = &amp;HFF And b(index + 1) = &amp;HD8 And b(index + 2) = &amp;HFF Then position = index Exit For End If Next If position &gt; 0 Then Dim jpgStream As New System.IO.MemoryStream(b, position, b.Length - position) oImage = New Bitmap(jpgStream) End If End If End If End If Catch ex As Exception Throw New ApplicationException(ex.Message, ex) End Try Return oImage End Function </code></pre> <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> It worked fine but im guessing i could have removed the serialisation stuff in a better way, perhaps theres an API to do it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload