0

I am using DataModule on the server which contains ADOConnection, ADOQuery and DataSetProvider. In ADOQuery SQL property I specify a query with a several parameters. In client application through the ClientDataSet I want to send a several input parameters to the server's data set. I know how to send only one parameter as described in the code below:

with ClientDataSet1 do
Data:= DataRequest(Edit1.Text);
Open;

How can I specify several query input parameters (e.g. Edit1.Text and Edit2.Text) in DataRequest function? Thanks!

  • The parameters in the query will be transferred to the CDS when you right-click and choose "Fetch parameters". Then you can use CDS.Params.ParambyName('param1').AsString := Edit1.Text and so on. All the values will be passed via the DSP to the Query. – Freddie Bell May 23 '18 at 11:12
  • @nolaspeaker, as a result, DataRequest function doesn't required there, right? – Nick Sheinov May 23 '18 at 11:18
  • Your code doesn't make sense to me, so all I can tell you is the way that I usually pass parameter values from the CDS to the Query. The method I described also works if the Query is in a Datasnap server. – Freddie Bell May 23 '18 at 11:43
  • @nolaspeaker, ok, then I should specify the same parameters in CDS and in Query "parameters" property, isn't it? – Nick Sheinov May 23 '18 at 11:58
  • You don't have to do it by code. You can do it at designtime. Right click on the CDS and choose "fetch parameters" from the context menu. – Freddie Bell May 23 '18 at 12:47
  • @nolaspeaker, ok, I understand. I will try it, thanks – Nick Sheinov May 23 '18 at 13:05
  • @nolaspeaker I tried your method, it works, but is it really good practise? Imagine the situation when names of parameters and their count in query on the server will be changed, so remote client app willn't know about this changes. it will fetch parameters but try to find old names of parameters through the ParamByName method. Client app cann't know names of server query parameters, right? Is there any way to cope with described situation? – Nick Sheinov May 24 '18 at 08:32
  • The idea here is that you have 1 CDS for each query. Connection->query->provider->CDS. It is very difficult to have changeable queries that also supply read-write data to CDS by this mechanism. – Freddie Bell May 24 '18 at 08:51
  • ok, thanks for explanations! – Nick Sheinov May 24 '18 at 08:57
  • There are ways to do this. It's just not possible to explain how to do it in the comments to a question. Ask another SO question. Show us what you tried to do. – Freddie Bell May 24 '18 at 09:05

0 Answers0