It is currently Fri May 27, 2016 11:58 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Feb 18, 2005 6:25 am 
Site Admin

Joined: Wed May 21, 2003 7:41 am
Posts: 951
This question pops up often, but the solution is not specific to MyComponents, and will work in and with any Borland dataset component (in fact, this is how you are suppose to do it in Delphi/Kylix):

File or Stream:

the following of course also works:

or you can also use the LoadFromStream and SaveToStream methods.

NOTE: If you post blobs to a table in MySQL you should keep a couple of things in mind:
1. The blob value is sent to the MySQL using a standard SQL statement. For this purpose, the value is hexed by the dataset and thus 2 SQL characters=1 blob byte.
2. Most MySQL servers' "max_allowed_packet" variable is set to a default value of less than 1Mb and a single sql statement must fit within one packet and thus within this variable's value. Thus if you submit a 1Mb blob then this variable needs to be at least 2Mb in size else you will get a 2006 - "MySQL server has gone away" or 2013 - "Lost connection to mysql server " error.

Of course, if you wish to compile your own SQL to insert or update a BLOB column, should you utilize the Dataset.EscStr or MySQLServer.EscapeStr methods at the very minimum to correctly escape any clashing embedded values inside the value. Best method, however, is to use Dataset.HexStr to convert your blob value to the hexed equavalent, ex:

Dataset.ExecSQL('insert into myblobtable set BlobField="'+Dataset.EscStr(Memo.Lines.Text)+'"');

Dataset.ExecSQL('insert into myblobtable set BlobField='+Dataset.HexStr(Memo.Lines.Text));

Using TField or a Macro
When you use the default TField or dataset macros are blob values automatically handled for you, ex:

TBlobField(Dataset.FieldByName('BlobField')).AsString := Memo.Lines.Text;
Dataset.MacroByName('BlobValueMacro').AsString := Memo.Lines.Text;

Hope this helps. For further information on this and related issues: ... large.html

Best wishes, Support

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group