Dan Palley Guest
|
Posted: Thu Mar 03, 2005 9:00 pm Post subject: Re: delphi 7 clearing the params of client data sets |
|
|
<user (AT) domain (DOT) invalid> wrote
| Quote: | I have a client dataset with a parameter :
cdsOne : TClientDataSet => Param1 => paramtype = ptInput, field type
ftInteger.
In the appserver, I have a TIbQuery with the same param, and a data set
provider.
Back in the client, I have a method :
RequeryTheCds(aParam : Integer) ;
begin
with cdsOne do
begin
Active := False ;
Params.ParamByName('Param1').AsInteger := aParam ;
Active := True ;
end ;
end ;
If I compile this code with delphi 6 it works ok all the time.
If I compile this code with delphi 7 it only works when the parameter
passed into the function ReQueryTheCds(aParam) is different from the one
passed immediately before : ie, if I try to query twice for the same
parameter, the second time the parameter gets converted to a null.
|
I ran into the same problem after moving from D6 to D9. I've entered a QC
entry for it (#10773) although my original problem was slightly different.
My work-around for now is to use a custom TClientdataset component. You
only need to override the DoGetRecords Method and comment out the call to
UnPackParams():
Type
TFixedClientDataSet = class(TClientDataSet)
protected
function DoGetRecords(Count: Integer; out RecsOut: Integer; Options:
Integer;
const CommandText: WideString; Params: OleVariant): OleVariant;
override;
end;
function TFixedClientDataSet.DoGetRecords(Count: Integer; out RecsOut:
Integer;
Options: Integer; const CommandText: WideString; Params: OleVariant):
OleVariant;
var
OwnerData: OleVariant;
begin
DoBeforeGetRecords(OwnerData);
Result := AppServer.AS_GetRecords(ProviderName, Count, RecsOut, Options,
CommandText, Params, OwnerData);
// Comment out the following line to fix params being cleared
// UnPackParams(Params, Self.Params);
DoAfterGetRecords(OwnerData);
end;
Dan
|
|