|
@@ -2294,18 +2294,36 @@ procedure TDataset.SetFieldValues(const Fieldname: string; Value: Variant);
|
|
var
|
|
var
|
|
i : Integer;
|
|
i : Integer;
|
|
FieldList: TList;
|
|
FieldList: TList;
|
|
|
|
+ hb, lb: integer;
|
|
begin
|
|
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;
|
|
end;
|
|
|
|
|
|
Function TDataset.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions) : boolean;
|
|
Function TDataset.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions) : boolean;
|