How to make sure that Parameters have been updated in a Dataset Provider
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 开发者_Go百科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?
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;
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.
精彩评论