When you use parameters, you need to set them in the "Parameters" property more when you need to make some change is need, for example, loading the fields from your table you may have problems is you need to reset everything again in the same way that if you need to set fields mascara you should use the Before Open event. I usually use (Adoquery + Datasetprovider + Clientdataset). I don’t use parameters, I do the queries using pure sql.
You can mount up to a precedent so that you can make all your queries, usually I create an Adoquery only for queries as follows: (sqlGenerico + dspGenerico + cdsGenerico);
//adicionar no type
procedure ConsultaDadosGenerico(NomeDoClienteDataSet:TClientDataSet; sqlConsulta :String);
procedure TForm1.Button1Click(Sender: TObject);
begin
ConsultaDadosGenerico(cdsCliente, 'Select * from controle where ribbons = ' + QuotedStr(Trim(Edit1.Text)) );
end;
procedure TForm1.ConsultaDadosGenerico(NomeDoClienteDataSet: TClientDataSet; sqlConsulta :String);
begin
NomeDoClienteDataSet.Close;
NomeDoClienteDataSet.CommandText := '';
NomeDoClienteDataSet.CommandText := sqlConsulta;
NomeDoClienteDataSet.Open;
end;
It worked exactly as I wanted it.
– Guilherme Lima