* Fixed bug ID #25091

git-svn-id: trunk@26661 -
This commit is contained in:
michael 2014-02-03 10:00:33 +00:00
parent 949907f1f3
commit 7afd5f6afe

View File

@ -2294,18 +2294,36 @@ procedure TDataset.SetFieldValues(const Fieldname: string; Value: Variant);
var
i : Integer;
FieldList: TList;
hb, lb: integer;
begin
if VarIsArray(Value) then begin
FieldList := TList.Create;
try
GetFieldList(FieldList, FieldName);
for i := 0 to FieldList.Count -1 do
TField(FieldList[i]).Value := Value[i];
finally
FieldList.Free;
end;
end else
FieldByName(Fieldname).Value := Value;
FieldList := TList.Create;
try
GetFieldList( FieldList, FieldName );
if VarIsArray( Value ) then
begin
if ( FieldList.Count > 1 ) then
begin
if ( VarArrayDimCount( Value ) <> 1 ) then
DatabaseErrorFmt('Variant Array Dimension Mismatch: Expected 1, got %d',[VarArrayDimCount( Value )],Self);
hb := VarArrayHighBound( Value, 1 );
lb := VarArrayLowBound( Value, 1 );
if hb - lb + 1 <> FieldList.Count then
DatabaseErrorFmt('Variant Array Value Count Mismatch: Expected %d, got %d',[FieldList.Count, hb - lb + 1],Self);
for i := 0 to FieldList.Count -1 do
TField(FieldList[i]).Value := Value[i+lb];
end
else
// Allow for a field type that can deal with an array.
FieldByName(Fieldname).Value := Value;
end
else
if FieldList.Count = 1 then
FieldByName( Fieldname ).Value := Value
else
DatabaseErrorFmt('Field Count Mismatch: Expected 1, got %d',[FieldList.Count],Self);
finally
FieldList.Free;
end;
end;
Function TDataset.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions) : boolean;