Advertisement

03.10.2008 at 12:21PM PDT, ID: 23229602
[x]
Attachment Details

How do I retrieve Ole Object (jpg file) from MSAccess 2003 using C#?

Asked by cyberE-gor in Microsoft Visual C#.Net, Microsoft Access Database

Tags: Microsoft, C#, MSAcess 2003, 'Parameter is not valid'

I can retrieve an OLE Object from Northwind database and change it to a c# Bitmap object.
I used an offset of 78 when reading the byte array. (see code snippet)

But I can't convert the OLE Object from db1(Access database) into a c# Bitmap object.
I have tried offset value from 0 to pictureData.Length. (see code snippet)

Here is a link to my sample database called db1.mdb
     http://www.mediafire.com/?1dgohmwqmmuStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
            OleDbConnection conn = new OleDbConnection("MyConnectionString");
            conn.Open();
            OleDbCommand query = new OleDbCommand("SELECT fldOLE FROM Table1", conn);
            byte[] pictureData = (byte[])query.ExecuteScalar();
            offsetValue = 78;
            Stream stream = new MemoryStream();
            stream.Write(pictureData, offsetValue, pictureData.Length - offsetValue);
            Image picture = Image.FromStream(stream);
 
Loading Advertisement...
 
[+][-]03.14.2008 at 10:11PM PDT, ID: 21131542

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, Microsoft Access Database
Tags: Microsoft, C#, MSAcess 2003, 'Parameter is not valid'
Sign Up Now!
Solution Provided By: puppydogbuddy
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628