Quote
On Sun, 04 Oct 1998 01:18:28 +0200, in5y...@public.uni-hamburg.de wrote:
>I have to send an image to MS-SQLSERVER (gif).
>Who knows how to load a blob from a file and pass it to the sql
>component.
First, represent the BLOB or memo column in the SQL statement as a
parameter. For example:
INSERT INTO YourTable
(KeyField, BlobField)
VALUES ("AAA", :BlobParam)
Then, before executing the SQL statement, provide the parameter with a
value. There are quite a number of ways to fill a BLOB or memo parameter
with a value. Which you use depends on what form the source data is in at
the time. All ways of doing this involve properties or methods of the
TParam object; some may involve external objects.
If the source data is in the form of a file, you can use the
TParam.LoadFromFile method to copy from file to parameter.
Query1.ParamByName('BlobParam').LoadFromFile('c:\windows\waves.bmp');
If the source data is in a PChar (or equivalent) buffer, you can directly
assign the buffer to the parameter using the TParam.AsMemo or TParam.AsBlob
property.
Query1.ParamByName('BlobParam').AsBlob := PBuffer;
If the data is contained in an object, such as a TBitmap, you can use the
TParam.Assign method.
Query1.ParamByName('BlobParam').Assign(Image1.Picture.Bitmap);
If it is in a stream (such as a TMemoryStream or TFileStream), use the
TParam.LoadFromStream method.
A TBlobStream object can also be used as an intermediary object to copy
data from a stream or a PChar buffer to a BLOB column.
//////////////////////////////////////////////////////////////////////////
Steve Koterski "The knowledge of the world is only to
Technical Publications be acquired in the world, and not in a
INPRISE Corporation closet."
http://www.inprise.com/delphi -- Earl of Chesterfield (1694-1773)