Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDQuery - & or ! is missing



Permlink Replies: 3 - Last Post: Dec 21, 2016 1:10 AM Last Post By: Dmitry Arefiev
Clement Lee

Posts: 5
Registered: 8/27/11
TFDQuery - & or ! is missing
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 8, 2016 6:28 PM
Hi,

the below is the example:

myStr := 'Testing string !';
fdQeury.SQL.Add('Update table Set password =' + QuotedStr(myStr));
fdQeury.ExecSQL;

I check the column value in the DB, and it becomes 'Testing string'. '!' is missing.
Another example, '&&&&&' will become '&&&&'.

I have to add the below codes in order to insert correctly.
fdQeury.ResourceOptions.MacroCreate := False;
fdQeury.ResourceOptions.MacroExpand := False;

Can anyone let me know:
1) If I set the MacroCreate and MacroExpand to false, will it cause other problem?
2) Is there any way to set them to false as default?

Thanks.

Robert Triest

Posts: 687
Registered: 3/24/05
Re: TFDQuery - & or ! is missing
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 4:22 AM   in response to: Clement Lee in response to: Clement Lee
myStr := 'Testing string !';
fdQeury.SQL.Add('Update table Set password =' + QuotedStr(myStr));
fdQeury.ExecSQL;

Don't know if this is the problem but..
Always use parameters in your query. Don't QuotedStr (or IntToStr) things in your SQL statement.
You will get problems also when you have to query DateTime fields.
(Database datetime fields expect different input according to the region setting)

myStr := 'Testing string !'; 
fdQeury.SQL.Add('Update table Set password= :Password');
fdQeury.ParamByName('Password').AsString:=myStr;
fdQeury.ExecSQL;
Clement Lee

Posts: 5
Registered: 8/27/11
Re: TFDQuery - & or ! is missing
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 6:20 PM   in response to: Robert Triest in response to: Robert Triest
Robert Triest wrote:
myStr := 'Testing string !';
fdQeury.SQL.Add('Update table Set password =' + QuotedStr(myStr));
fdQeury.ExecSQL;

Don't know if this is the problem but..
Always use parameters in your query. Don't QuotedStr (or IntToStr) things in your SQL statement.
You will get problems also when you have to query DateTime fields.
(Database datetime fields expect different input according to the region setting)

myStr := 'Testing string !'; 
fdQeury.SQL.Add('Update table Set password= :Password');
fdQeury.ParamByName('Password').AsString:=myStr;
fdQeury.ExecSQL;

Thanks a lot :)
I think to use parameter is the best solution.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TFDQuery - & or ! is missing
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 21, 2016 1:10 AM   in response to: Clement Lee in response to: Clement Lee
1) If I set the MacroCreate and MacroExpand to false, will it cause other problem?

No problems, if you does not use FireDAC macros.

2) Is there any way to set them to false as default?

Set them at FDConnection of FDManager level or even in connection definition using FDExplorer.
And all FireDAC datasets will inherit these settings.

--
With best regards,
Dmitry
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02