PDA

Click to See Complete Forum and Search --> : saving an image to Sybase


Apr 19th, 2000, 02:57 AM
What I would like to do is store a random file to Sybase as an image. Now I have been successful in doing this for files smaller then 1MB, anything larger then this size it simply truncates the file. Now I have investigated the Sybase end of it and I think everything on that side of the system is fine. I am storing the file as an image type in a table, which excepts images of up to 2.1GB.

Now on the VB end of things I am writing the image using the code below:

ReDim Chunk(ChunkSize)
For ii = 1 To Chunks
Get FileHandle, , Chunk()
rs(jj).AppendChunk Chunk()
Next ii

Where "Chunks" is the number of chunks in the file. I also write a fragment chunk after the majority of the file has been read.

Other information:

rs(jj).ChunkRequired - this returns TRUE, so it knows that the column is a BLOB

rs(jj).ColumnSize - this returns 2.1 GB, so it also knows what Sybase will except.

So my question is, why does it only save a maximum of 1MB?

Mongo
Apr 20th, 2000, 03:49 AM
Your 1MB limit hints that your table's field datatype is not TEXT or IMAGE. Sybase SQL Server has a row size limit of 1962 bytes for all but TEXT/IMAGE datatypes. I've known people go binary-BLOB on the brain and choose a binary datatype when they meant to use TEXT or IMAGE. Either of these will permit up to 2MG, while the other types won't. You might double-check there. If you're fighting through the classic DBA/code-cutter love/mostly hate paradox, run a quick sp_help [table name] in WISQL to get the answer.

If you're hell-bent on using an MS/Borland "chunk" approach, be sure you use a chunksize setting of 1800 for all but your last. Otherwise, you're forcing an extra K per write and fueling your DBA's distain for the rest of us.

It may be more efficient to abandon chunking and let Sybase Server do the grunt work for you with a simple stored procedure or straightforward SQL INSERT statement. This would simplify including a photo ID cross-reference, which you haven't mentioned. If you have access to the pubs database, the look at the stuff about the pub_info table as it relates to the publishers table -- I think it's much like what you're trying to accomplish.

I'll try to check back here again in a few days, so please let me know if you'd like any other ideas or further details. Hope this helps! ;-)