Storing values in TBlobField using sql

Sandeep Chandra picture Sandeep Chandra · Jan 11, 2010 · Viewed 8k times · Source

I want to store images into a database using SQL commands, I know other ways using TBlobField.LoadFromFile etc, but we make our own sql commands to update the database that's why I need to do this.

How should I go about doing this?

Answer

Graza picture Graza · Jan 11, 2010

I've never tried this (and away from desk at the moment), but would parameters work? eg:

Query.Sql.Clear;
Query.Sql.Add('update myTable set myField = :blobVal where myId = :idVal');
Query.ParamByName('idVal').AsInteger := SomeId;
Query.ParamByName('blobVal').LoadFromFile(....
//or
Query.ParamByName('blobVal').LoadFromStream(....
Query.ExecSql;

This allows you to use SQL (rather than the .Edit, etc methods) and still insert blob data