views:

61

answers:

2

In a Delphi app we have assigned a dataset provider with a TADOQuery, passing parameters to the Query. When the TADOQuery is refreshed with new parameter values these are not being passed to the Dataset Provider.

This seemed to work ok in Delphi 5, but we are migrating our application to Delphi 2010 and it seems to have broken this link.

Is there a way of refreshing the parameters against the dataset provider with the new values?

A: 

I've been doing it the following way for years. I never knew that you could just refresh the query in Delphi 5 to re-prepare the query:

oADOQuery.Active := False;
oADOQuery.Params.ParamByName('MyParam').AsString := 'New Value';
oADOQuery.Active := True;

I believe it's the standard way.

Marcus Adams
+1  A: 

We have had a response from Embarcadero on this one, and it seems that there is still a bug connecting dbx components to a client dataset and refreshing parameters, there should not be a problem with dbgo ADO Components.

However, there is a a way of doing this with a Dataset Provider and that is to call FetchParams prior to setting the query active. i.e.

QProvider := oADOQuery;
oADOQuery.Active := False;
oADOQuery.Params.ParamByName('MyParam').Value := 'New Value';
QProvider.FetchParams;
oADOQuery.Active := True;
Matt
@Matt, notice here in StackOverflow you're allowed to accept your own answer. If this is not an answer but part of the original question, you should edit the question or add comments to it. I don't realize why you're posting an answer but not accepting it.
jachguate
@jachguate - thanks :)
Matt