Saving an image with AppendChunk problem

Saving an image with AppendChunk problem

Post by Pit » Sat, 18 Mar 2000 04:00:00


Hello there,

I'm a vb-programmer and new to mssql.
I've got a problem saving binary data from an image (.jpg or .bmp) to
an image-type field in a MsSql 7.0 database.
Here's what i do; First I open the .bmp or .jpg for binary read.
Determine the size of the image and set the size of the chunks to 1K,2K,
4Kor 8K.
Then i'm getting the chunks from the file and saving the chunks by applying
the AppendChunk method.
So far so good. Now when i try to get the data from the image-field to store
in a temporary file for
loading into an image control, the data in the image-field appears to be
twice the size of the original
image. I did a number of tests. First i checked what the ActualSize of the
image-field was directly after
the saving the first chunk. The ActualSize is then indeed twice the size of
the chunk. (i'm not saving it twice)
So it seems sql is adding an extra byte for each byte saved.
I also tried to save the data into a binary and a varbinary field.
In this case the AppendChunk method raises an error; Error 3219 Method not
permitted in this context.
Does anyone have a solution for this problem ??
Another data-type maybe or a solution for the 'double size'.

Thanks in advance, Leon


 
 
 

Saving an image with AppendChunk problem

Post by Steve Foste » Mon, 20 Mar 2000 04:00:00


I seem to remember bumping into this problem a couple of years ago. If I
remember rightly, VB is lying. I suggest you try writing the data you
read out to a file, and then checking how big the file is... I think
you'll find it will be the right size, and that VB gets the data count
wrong.

Steve.

-----Original Message-----

Posted At: 17 March 2000 6:00pm
Posted To: microsoft.public.sqlserver.odbc
Conversation: Saving an image with AppendChunk problem
Subject: Saving an image with AppendChunk problem

Hello there,

I'm a vb-programmer and new to mssql.
I've got a problem saving binary data from an image (.jpg or .bmp) to
an image-type field in a MsSql 7.0 database.
Here's what i do; First I open the .bmp or .jpg for binary read.
Determine the size of the image and set the size of the chunks to 1K,2K,
4Kor 8K.
Then i'm getting the chunks from the file and saving the chunks by
applying
the AppendChunk method.
So far so good. Now when i try to get the data from the image-field to
store
in a temporary file for
loading into an image control, the data in the image-field appears to be
twice the size of the original
image. I did a number of tests. First i checked what the ActualSize of
the
image-field was directly after
the saving the first chunk. The ActualSize is then indeed twice the size
of
the chunk. (i'm not saving it twice)
So it seems sql is adding an extra byte for each byte saved.
I also tried to save the data into a binary and a varbinary field.
In this case the AppendChunk method raises an error; Error 3219 Method
not
permitted in this context.
Does anyone have a solution for this problem ??
Another data-type maybe or a solution for the 'double size'.

Thanks in advance, Leon



 
 
 

Saving an image with AppendChunk problem

Post by Brian Perkin » Wed, 12 Apr 2000 04:00:00



Quote:> I seem to remember bumping into this problem a couple of years ago. If I
> remember rightly, VB is lying. I suggest you try writing the data you
> read out to a file, and then checking how big the file is... I think
> you'll find it will be the right size, and that VB gets the data count
> wrong.

> Steve.

Pit and Steve,

As crazy at it seems, I've found this to be true also.  It IS reporting the
"ActualSize" (ha!) as being double what it really is.  Like you said Steve,
when I save it out, the file is the correct size.

I wonder if you can count on it always being wrong?  (i.e. divide the number
reported by ActualSize by two.)  I also wonder if it has something to do
with the fact that I'm running on NT4(sp6a).  Does anyone know if this
occurs on w95/w98?  What about Win2k?

With Micro$oft, you just never know what to expect!  Do you???

Brian
--
Reply address is "antispamulated" - real address is: briankperkins (at)
geocities.com
"Do, or do not... There is no try!" - Yoda
--

 
 
 

1. Saving an image with AppendChunk problem

Hello there,

I'm a vb-programmer and new to mssql.
I've got a problem saving binary data from an image (.jpg or .bmp) to
an image-type field in a MsSql 7.0 database.
Here's what i do; First I open the .bmp or .jpg for binary read.
Determine the size of the image and set the size of the chunks to 1K,2K,
4Kor 8K.
Then i'm getting the chunks from the file and saving the chunks by applying
the AppendChunk method.
So far so good. Now when i try to get the data from the image-field to store
in a temporary file for
loading into an image control, the data in the image-field appears to be
twice the size of the original
image. I did a number of tests. First i checked what the ActualSize of the
image-field was directly after
the saving the first chunk. The ActualSize is then indeed twice the size of
the chunk. (i'm not saving it twice)
So it seems sql is adding an extra byte for each byte saved.
I also tried to save the data into a binary and a varbinary field.
In this case the AppendChunk method raises an error; Error 3219 Method not
permitted in this context.
Does anyone have a solution for this problem ??
Another data-type maybe or a solution for the 'double size'.

Thanks in advance, Leon

2. How do I keep from creating new tasks on the Windows Taskbar?

3. DATABASE & CLIENT/SERVER WORLD Conference & Exposition (BXKQM07)

4. Save Image In DB better or save path ????

5. TEMPORARY DATABASE

6. AppendChunk'in to SQL 6.5 image or varbinary field

7. Reccomendations for Client/Server Database -- front end

8. Problem Saving images from OLE to file

9. Strange problem with appendchunk, stranger solution yet

10. AppendChunk problems with SQL Server

11. DAO getchunk/appendchunk problems in Access 97 DB

12. AppendChunk Problem ???