I will start off with, it is not worth storing images in MS-Access for many reasons and that I was interested to hear if anyone else may have seen this.
My reason for this post is out of curiosity than a need to provide a solution to someone or for me to use it.
While attempting to answer a question on another forum regarding viewing and updating images stored in an MS-Access table-MDB not ACCDB (and I suggested they store the images to a folder) I ran into an issue, which seem odd. The code read bytes into a memory stream to instantiate a new image object and received an error Parameter is not valid. Sometime ago I wrote code against an MDB using the same methods just mentioned and worked fine yet fails on ACCDB.
After tinkering a bit I thought perhaps the offset in the BLOB was not at the beginning of the bytes and used a brute force method to locate the start position of the image in the BLOB field. After all the field is an array of bytes and maybe MS-Access uses part of this to indicate information stored in a field in a specific row.
So out of curiosity I took a random project found on the web which reads BLOB fields from MDB files and not ACCDB and it worked fine yet with a modified version failed on ACCDB files.
The project DBImage is not mine and was upgraded to VS2010 for the experiment and works just fine. The other project MS_Access_ImageTinkering is what I created to read BLOB data from ACCDB files.
In my project build/run, in the second ComboBox select 3 then press the find button which figures out the position for the row in the table where the image starts in the BLOB field. When it finds it by brute force it is displayed in a TextBox. Press Update and it is saved back to the database and is now available in the first ComboBox to display via the button labeled Get.
So now a question: Anyone know if there is an known formula to determine the starting position of the image in the BLOB?
VS2010 Solution with two project as per above. Both projects work, no errors if you use as is.
My reason for this post is out of curiosity than a need to provide a solution to someone or for me to use it.
While attempting to answer a question on another forum regarding viewing and updating images stored in an MS-Access table-MDB not ACCDB (and I suggested they store the images to a folder) I ran into an issue, which seem odd. The code read bytes into a memory stream to instantiate a new image object and received an error Parameter is not valid. Sometime ago I wrote code against an MDB using the same methods just mentioned and worked fine yet fails on ACCDB.
After tinkering a bit I thought perhaps the offset in the BLOB was not at the beginning of the bytes and used a brute force method to locate the start position of the image in the BLOB field. After all the field is an array of bytes and maybe MS-Access uses part of this to indicate information stored in a field in a specific row.
So out of curiosity I took a random project found on the web which reads BLOB fields from MDB files and not ACCDB and it worked fine yet with a modified version failed on ACCDB files.
The project DBImage is not mine and was upgraded to VS2010 for the experiment and works just fine. The other project MS_Access_ImageTinkering is what I created to read BLOB data from ACCDB files.
In my project build/run, in the second ComboBox select 3 then press the find button which figures out the position for the row in the table where the image starts in the BLOB field. When it finds it by brute force it is displayed in a TextBox. Press Update and it is saved back to the database and is now available in the first ComboBox to display via the button labeled Get.
So now a question: Anyone know if there is an known formula to determine the starting position of the image in the BLOB?
VS2010 Solution with two project as per above. Both projects work, no errors if you use as is.