[Lazarus] Inserting images in mysql records

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Fri May 4 11:45:47 CEST 2012



On Fri, 4 May 2012, Hugues Moisy wrote:

> Hi all,
>
> I'm trying to insert gif file content into a blob field in a mysql 
> database. Insertion process works, but the size of the data inserted is 
> cut to 64 Kbytes, so the images are cut and impossible to read (crash), 
> except those that are less than 64KB.
>
> my function is this :
>
>       conn := getConnection(_TypeConnection);
>       query.DataBase := conn;
>       query.UsePrimaryKeyAsKey:=false;
>
>       query.SQL.clear;
>       query.SQL.Add('update volumepage set page_image = :image, 
> image_filename = :imgname where volume_id = :vol and page_index = :page');
>       query.Params.ParamByName('vol').Value:=pVolumeId;
>       query.Params.ParamByName('page').Value:=pPageIndex;
>       query.Params.ParamByName('image').LoadFromFile(pFileName,ftBlob);
>       query.Params.ParamByName('imgname').Value:=pFileName;
>
>       query.ExecSQL;
>
> could somebody explain me the origin of the problem : is it a problem in 
> the database, or in the LoadFromFile ?

It depends on the type of field you created in the database. 
If it is a 'Text' field, then I think Mysql limits the content to 64k bytes.

sqldb by itself does not impose limits, as far as I know.

Michael.




More information about the Lazarus mailing list