* Fixed bug ID #8201

git-svn-id: trunk@30435 -
This commit is contained in:
michael 2015-04-05 10:12:46 +00:00
parent 844cf495f8
commit d63961ce02
3 changed files with 46 additions and 30 deletions

View File

@ -90,39 +90,37 @@ begin
FCalcFieldsSize := 0; FCalcFieldsSize := 0;
FBlobFieldCount := 0; FBlobFieldCount := 0;
for i := 0 to Fields.Count - 1 do for i := 0 to Fields.Count - 1 do
with Fields[i] do begin with Fields[i] do
begin
FFieldDef:=Nil; FFieldDef:=Nil;
if Binding then begin if not Binding then
if FieldKind in [fkCalculated, fkLookup] then begin FFieldNo := 0
FFieldNo := -1; else if FieldKind in [fkCalculated, fkLookup] then
FOffset := FCalcFieldsSize; begin
Inc(FCalcFieldsSize, DataSize + 1); FFieldNo := -1;
if FieldKind in [fkLookup] then begin FOffset := FCalcFieldsSize;
if ((FLookupDataSet = nil) or (FLookupKeyFields = '') or Inc(FCalcFieldsSize, DataSize + 1);
(FLookupResultField = '') or (FKeyFields = '')) then end
DatabaseErrorFmt(SLookupInfoError, [DisplayName]); else
FFields.CheckFieldNames(FKeyFields); begin
FLookupDataSet.Open; FFieldDef := nil;
FLookupDataSet.Fields.CheckFieldNames(FLookupKeyFields); FieldIndex := FieldDefs.IndexOf(Fields[i].FieldName);
FLookupDataSet.FieldByName(FLookupResultField); if FieldIndex <> -1 then
if FLookupCache then RefreshLookupList; begin
end FFieldDef := FieldDefs[FieldIndex];
end else begin FFieldNo := FFieldDef.FieldNo;
FFieldDef := nil; if FieldDef.InternalCalcField then
FieldIndex := FieldDefs.IndexOf(Fields[i].FieldName); FInternalCalcFields := True;
if FieldIndex <> -1 then begin if IsBlob then
FFieldDef := FieldDefs[FieldIndex]; begin
FFieldNo := FFieldDef.FieldNo; FSize := FFieldDef.Size;
if FieldDef.InternalCalcField then FInternalCalcFields := True; FOffset := FBlobFieldCount;
if IsBlob then begin Inc(FBlobFieldCount);
FSize := FFieldDef.Size;
FOffset := FBlobFieldCount;
Inc(FBlobFieldCount);
end; end;
end else FFieldNo := 0; end
end; end;
end else FFieldNo := 0; Bind(Binding);
end; end;
end; end;
function TDataSet.BookmarkAvailable: Boolean; function TDataSet.BookmarkAvailable: Boolean;

View File

@ -322,6 +322,7 @@ type
procedure CheckInactive; procedure CheckInactive;
class procedure CheckTypeSize(AValue: Longint); virtual; class procedure CheckTypeSize(AValue: Longint); virtual;
procedure Change; virtual; procedure Change; virtual;
procedure Bind(Binding: Boolean); virtual;
procedure DataChanged; procedure DataChanged;
procedure FreeBuffers; virtual; procedure FreeBuffers; virtual;
function GetAsBCD: TBCD; virtual; function GetAsBCD: TBCD; virtual;

View File

@ -384,6 +384,23 @@ begin
end; end;
end; end;
procedure TField.Bind(Binding: Boolean);
begin
if Binding and (FieldKind=fkLookup) then
begin
if ((FLookupDataSet = nil) or (FLookupKeyFields = '') or
(FLookupResultField = '') or (FKeyFields = '')) then
DatabaseErrorFmt(SLookupInfoError, [DisplayName]);
FFields.CheckFieldNames(FKeyFields);
FLookupDataSet.Open;
FLookupDataSet.Fields.CheckFieldNames(FLookupKeyFields);
FLookupDataSet.FieldByName(FLookupResultField);
if FLookupCache then
RefreshLookupList;
end;
end;
procedure TField.Change; procedure TField.Change;
begin begin