Backspaces SQLite FireDAC
I am using Delphi XE7 with FireDAC to access SQLite.
When I put data in the TEXT field, any trailing spaces or # 0 characters are truncated.
Is there something I can change in SQLite or FireDAC so that it preserves the trailing space?
// The trailing spaces after Command don't come back from SQLite.
fFireDACQuery.ParamByName(kSQLFieldScriptCommands).AsString := 'Command ';
+3
source to share
1 answer
Disable the StrsTrim property . This property is described as:
TFDFormatOptions.StrsTrim
Controls the removal of trailing spaces from string values ββand zero bytes from binary values.
And it seems that you want to store binary data, not text. If this is correct, you better define your field datatype, eg. as BINARY [255] for a binary string of fixed length 255 bytes (255 is the maximum length of the ShortString you are using).
The parameter value for such a field, which you would get this way:
var
Data: RawByteString;
begin
ReadByteDataSomehow(Data);
FDQuery.FormatOptions.StrsTrim := False;
FDQuery.SQL.Text := 'INSERT INTO MyTable (MyBinaryField) VALUES (:MyBinaryData)';
FDQuery.ParamByName('MyBinaryData').AsByteStr := Data;
FDQuery.ExecSQL;
end;
+2
source to share