Firedac select working with Firebird returns no records

混江龙づ霸主 提交于 2020-01-04 05:45:19

问题


Hello I'm working with Firedac (Delphi Seattle) using Firebird (2.5) as a database, when I run this query using a TFDQuery, no records are returned:

SELECT ID FROM USERS WHERE PWD = 'êHÆ–!+'

The same query within a Database program as IbExpert return one record. Is there some parameter with Firedac components to configure that can solve this issue. Thanks.


回答1:


It's in the query string and it's the ! char. By default, query strings are preprocessed, and you must escape constant chars like !, &, :, ?, { or }, otherwise they are used as special chars.

Your best option is using parameters. That will (except other benefits) get rid of that ! char from the preprocessed command:

FDQuery.SQL.Text := 'SELECT ID FROM USERS WHERE PWD = :Password';
FDQuery.ParamByName('Password').AsString := 'êHÆ–!+';
FDQuery.Open;

Another option is escaping that constant char or disable macro preprocessor. For more information see the Special Character Processing topic.



来源:https://stackoverflow.com/questions/43465988/firedac-select-working-with-firebird-returns-no-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!