bazzer747 25 Posted March 28, 2020 Hi, I have searched for 'simple' stuff in using FireDac but havn't found the answer to the following, which would save me lots of keying ... I have a datamodule with a fdQuery & Datasource, and the fdQuery has the following: 'Select * from tTable where Company = :pC order by oOrderName' - so a parameter is created in the query. If in my code I want to set the query to different values do I have to do the select statement again in it's entirety, like: dm.fdc.Open( 'Select * from tTable where Company = :pC order by oOrderName', [ 'Debenhams'] ); Or can I simply specify the new parameter value like: dm.fdc.Open( '', [ 'Woolworths' ); Share this post Link to post
ergeka 5 Posted March 28, 2020 This should work: dm.fdc.Param.ParamByName('pC').asString := 'Woolworth'; dm.fdc.Open; Share this post Link to post
Serge_G 87 Posted March 29, 2020 Hello, This was a question I had in mind for a long time. I used to use, like ergeka and, even, closing the query before (old BDE comportment) dm.fdc.Close; dm.fdc.parambyname('Pc').asString:='Woolworths'; dm.fdc.Open; So, today, I make a little test and Firedac is really an amazing thing dm.fdc.Open,('',[ 'Woolworths' ]); works. One only line versus 2 (three in my case) and shorter than this ParambyName stuff. I certainly use this for now 😉 By the way I test also this query Select * from tTable where Company = ? order by oOrderName a no named parameter. It works too 👍 Share this post Link to post
bazzer747 25 Posted March 29, 2020 Many thanks, both - I will certainly use these methods. The shorter version Serge mentioned I saw in a YouTube on Tips & Tricks by Dmitry Arefiev CodeRage 9. Share this post Link to post