Hello,
This doesn't work. I've founded a similar example on the web and already
tryed. Nothing more. The problem is not really in the header of the data.
But more on how these data are retrived from db.
The value inside the field is correct. Because when I use a VBA function
(into an Access form) I get the image correctly on the disk.
But when use .Net I get a file wicth size is the exact double of the
original.
For example, here you'll find juste a little piece of the begining of the
original file (that work) and the one that has been generated from .net
Original:
FF D8 FF E0 00 10 4A 46 49 46 00 01 01
00 00 01
Generated file
FF 00 D8 00 FF 00 E0 00 00 00 10 00 4A
00 46 00
If a made a breakpoint directly after getting the value from the field with
ado.net and read the length of what i've retrived I get the orignial size *
2
I suppose that ADO.NET make something to bring me crazy :) So do I need to
change something I my connection string do tell ado to don't do anything
strange ?
string strConnectionString="Provider=Microsoft.Jet.OLEDB. 4.0;Data
Source=c:\test\photodb.mdb;User Id=admin;Password=;";
cnMDB = new OleDbConnection(strConnectionString);
OleDbCommand cmdPhoto = new OleDbCommand(strQuery,cnMDB);
cnMDB.Open();
OleDbDataAdapter da = new OleDbDataAdapter(cmdPhoto);
DataSet ds = new DataSet();
da.Fill(ds, "tblRefAlbum");
Just after this instruction, the field size in the memory is twice the size
of the original data in db.
Help I need somebody, Help......
"Trent Millar" <th****@hotmail.com> wrote in message
news:8IFjc.273614$Pk3.85830@pd7tw1no...
I know with some older image formats you must actually run ahead of some
of the old header input. For instance when using the Northwind database you
would have to edit your code below to this:
byte[] blob = (byte[]) (ds.Tables["employees"].Rows[0]["photo"]);
_stream.Write (blob, 78, blob.Length -78); // hack's out the old header
info _bitmap = new Bitmap (stream);
If you're certain that the images are there you should look into this as a
likely solution.
rgds,
Trent Millar
"Pierre-Benoit" <qu******@hotmail.com> wrote in message
news:cc**************************@posting.google.c om... Hi there,
I've a strange problem with ado.net and an Access db. I need to create
a little C# app that take the content of "ole object" field and then
save it into a file.
The problem is that when I do the following
Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])(ds.Tables["tblRefAlbum"].Rows[0]["photo"]);
I get the exact double of the original size! and if I save this array
byte to a file I'll get my file with every two byte set to 00.
The result is, of course, not an image. I've tryed to manipulate my
array of byte to strip every two bytes but the result is an visible
image but not the correct image (it's a scrambled image that appears).
Please help, I really need to do this exportation of picture in .net
with the access db.
Thanks a lot for people whom can help me.