your websnap application may throw a "Row not found" exception when some dataset is empty. maybe there are no problem with you, but Borland(not sure).
Let's open the DbAdapt.Pas Unit, and see the TCustomDataSetAdapter.LocateKeyParams function:
if {we should modity here}FieldList.Count <> 0 then
begin
...
Result := DataSet.Locate(KeyFields, KeyValues, []);
end
else
Result := True; // No locate params
thus, this method use Dataset's Locate method, but have not consider whether the dataset is empty. yes Locate method often return false when it search a empty dataset.
In the method which call this function, Like TCustomDataSetAdapter.SilentLocate and TCustomDataSetAdapter.Locate function, we can see the exception would be throw:
{In SilentLocate method}
Result := LocateKeyParams(TLocateParamsWrapper.Create(L));
......
{In Locate method}
if not SilentLocate(LocateParamsList, True) then
RaiseRowNotFound
...
fix it would be easy, just add a condition like this(if you have a better way, then tell me please)
{In TCustomDataSetAdapter.LocateKeyParams method}
if (Dataset.RecordCount <>0) and (FieldList.Count <> 0) then
begin
...
Result := DataSet.Locate(KeyFields, KeyValues, []);
end
else
Result := True;
by the way, you had better to modify the Unit and recompile it, then copy the dbadapt.dcu file to delphi's lib folder. if you add this Unit to your project and modify it, then build the project, your application maybe shutdown, I have meet this, but have not get the reason.
Delphi Version: D6,D7(?)
Good Luck!shaver
Let's open the DbAdapt.Pas Unit, and see the TCustomDataSetAdapter.LocateKeyParams function:
if {we should modity here}FieldList.Count <> 0 then
begin
...
Result := DataSet.Locate(KeyFields, KeyValues, []);
end
else
Result := True; // No locate params
thus, this method use Dataset's Locate method, but have not consider whether the dataset is empty. yes Locate method often return false when it search a empty dataset.
In the method which call this function, Like TCustomDataSetAdapter.SilentLocate and TCustomDataSetAdapter.Locate function, we can see the exception would be throw:
{In SilentLocate method}
Result := LocateKeyParams(TLocateParamsWrapper.Create(L));
......
{In Locate method}
if not SilentLocate(LocateParamsList, True) then
RaiseRowNotFound
...
fix it would be easy, just add a condition like this(if you have a better way, then tell me please)
{In TCustomDataSetAdapter.LocateKeyParams method}
if (Dataset.RecordCount <>0) and (FieldList.Count <> 0) then
begin
...
Result := DataSet.Locate(KeyFields, KeyValues, []);
end
else
Result := True;
by the way, you had better to modify the Unit and recompile it, then copy the dbadapt.dcu file to delphi's lib folder. if you add this Unit to your project and modify it, then build the project, your application maybe shutdown, I have meet this, but have not get the reason.
Delphi Version: D6,D7(?)
Good Luck!shaver
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货