473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

size problem with ole object data type (blob) and ado.net

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.
Nov 16 '05 #1
3 6040
Hi Pierre,

"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];
Byte[] byteBLOBData = (Byte[])(ds.Tables["tblRefAlbum"].Rows[0]["photo"]);

would be enough :).

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.


Are you sure that the data inside database is correct?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
Nov 16 '05 #2
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.

Nov 16 '05 #3
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.


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bj?rn Terje Svennes | last post by:
I'm using ODBC to interface a Microsoft SQL Server 2000. One of the operations involves placing files within BLOBs. I'm using the image data type for this purpose. Most of the time this works okey,...
6
by: Pierre-Benoit | last post by:
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...
2
by: Stanley Sinclair | last post by:
About to create a table which will "include" a BLOB. Am not sure how large to make the container and the tablespace. What I see says that BLOB is stored "separately." However, I don't know...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
7
by: johnm | last post by:
We have a new CRM application that uses a DB2 7.2 database. Our users noted that the CRM application would not allow them to attach and store any documents over 2 meg in size. When asked, the...
3
by: Ray | last post by:
I am having my first experience using BLOB as a row in a table. I am using it to insert graphics for labels we print. I have no problem inserting into and select from the table. The graphic is...
1
by: gimme_this_gimme_that | last post by:
In DB2, is it possible to update a table having a BLOB using a statement such as "SELECT MY_BLOB_FIELD FROM MY_TABLE FOR UPDATE" Then getting the Blob and writing to the Blob's output stream ? ...
4
by: Yaro | last post by:
Hi, I am looking for information how calculate size of table with BLOB field. After RUNSTATS command select fpages * tablespace pagesize - gives me only 16kB (table contain about 10M) I...
4
by: =?Utf-8?B?UHVjY2E=?= | last post by:
The function that I'm trying to call through DLLImport has a parameter that has a C code's vector's Itrator to a structure. I Have marshalled the structure in C# but how do I do the C type...
2
by: sjping | last post by:
This is what I did: >db2 alter table C1016781_T1 alter column itemContent set data type blob(2097152) and I got: DB21034E The command was processed as an SQL statement because it was not a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.