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 Alejandro Mes » Sat, 18 Mar 2000 04:00:00


It is a good idea not to save the file inside the db, save just the path to
the file and use it, for example, as the filename parameter in the
loadpicture function.


> 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:> It is a good idea not to save the file inside the db...

He didn't ask if it was a good idea - he asked how to do it!

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. SQL 2000 on XP PRO

3. SQL Enterprise Manager 6.5 ... Unable to connect to site because it is unavailable or does not exist.

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

5. Sybase 4.9.2 to 11

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

7. Completed Compression 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 ???