On Wed, 10 Feb 2016, Felipe Monteiro de Carvalho wrote:

Hello,

Taking advantage that we are already talking about SQL .... how to
upload the contents of a blob field?

I tried using a SELECT to get the field +
TBlobField(FQuery.FieldByName('Data')).LoadFromStream but it raises an
exception that "Dataset is not in insert or edit mode"

I see that I could write the data in hexadecimal in the SQL query, but
that would be slow...

So what is the proper way to use TBlobField.LoadFromStream?

Or should I use params + an SQL statement with question mark:

lSQL := Format('UPDATE %s SET ? WHERE ID=''%d''', [lTableName, AItemNr]);

Both ways are possible.

Qry.sql.text:='your select';
Qry.Open;
// Navigate to record you want to modify
Qry.Edit; // Go to edit mode.
TBlobField(FQuery.FieldByName('Data')).LoadFromStream(YourStream))
Qry.Post; // Save changes

Or

Qry.Sql.Text:='update tablename set (yourfield=:yourfield) where ID=something';
Qry.ParamByName('yourfield').LoadFromStream(YourStream)
Qry.ExecSQL;


Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to