|
@@ -1407,6 +1407,7 @@ var
|
|
i : integer;
|
|
i : integer;
|
|
aPacketReader : TDataPacketReader;
|
|
aPacketReader : TDataPacketReader;
|
|
aStream : TFileStream;
|
|
aStream : TFileStream;
|
|
|
|
+ doBind : boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
aPacketReader:=Nil;
|
|
aPacketReader:=Nil;
|
|
@@ -1421,8 +1422,23 @@ begin
|
|
aPacketReader := GetPacketReader(dfDefault, aStream);
|
|
aPacketReader := GetPacketReader(dfDefault, aStream);
|
|
end;
|
|
end;
|
|
IntLoadFieldDefsFromPacket(aPacketReader);
|
|
IntLoadFieldDefsFromPacket(aPacketReader);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ // Issue 40450: At design time, create a dataset, set to active.
|
|
|
|
+ // At runtime, open is called, but fields are not bound (this happens in createdataset)
|
|
|
|
+ // So we check for unbound fields and bind them if needed.
|
|
|
|
+ // Do not call bindfields unconditonally, because descendants may have called it.
|
|
|
|
+ I:=0;
|
|
|
|
+ DoBind:=False;
|
|
|
|
+ While (Not DoBind) and (I<Fields.Count) do
|
|
|
|
+ begin
|
|
|
|
+ DoBind:=Fields[i].FieldNo=0;
|
|
|
|
+ Inc(I);
|
|
|
|
+ end;
|
|
|
|
+ if DoBind then
|
|
|
|
+ BindFields(True);
|
|
end;
|
|
end;
|
|
-
|
|
|
|
// This checks if the dataset is actually created (by calling CreateDataset,
|
|
// This checks if the dataset is actually created (by calling CreateDataset,
|
|
// or reading from a stream in some other way implemented by a descendent)
|
|
// or reading from a stream in some other way implemented by a descendent)
|
|
// If there are less fields than FieldDefs we know for sure that the dataset
|
|
// If there are less fields than FieldDefs we know for sure that the dataset
|
|
@@ -1436,7 +1452,6 @@ begin
|
|
// if Fields.Count<FieldDefs.Count then
|
|
// if Fields.Count<FieldDefs.Count then
|
|
if (Fields.Count = 0) or (FieldDefs.Count=0) then
|
|
if (Fields.Count = 0) or (FieldDefs.Count=0) then
|
|
DatabaseError(SErrNoDataset);
|
|
DatabaseError(SErrNoDataset);
|
|
-
|
|
|
|
// search for autoinc field
|
|
// search for autoinc field
|
|
FAutoIncField:=nil;
|
|
FAutoIncField:=nil;
|
|
if FAutoIncValue>-1 then
|
|
if FAutoIncValue>-1 then
|
|
@@ -3676,17 +3691,15 @@ var
|
|
|
|
|
|
begin
|
|
begin
|
|
CheckInactive;
|
|
CheckInactive;
|
|
|
|
+ if ((Fields.Count=0) and (FieldDefs.Count=0)) then
|
|
|
|
+ raise Exception.Create(SErrNoFieldsDefined);
|
|
if ((Fields.Count=0) or (FieldDefs.Count=0)) then
|
|
if ((Fields.Count=0) or (FieldDefs.Count=0)) then
|
|
begin
|
|
begin
|
|
if (FieldDefs.Count>0) then
|
|
if (FieldDefs.Count>0) then
|
|
CreateFields
|
|
CreateFields
|
|
else if (Fields.Count>0) then
|
|
else if (Fields.Count>0) then
|
|
- begin
|
|
|
|
InitFieldDefsFromFields;
|
|
InitFieldDefsFromFields;
|
|
- BindFields(True);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- raise Exception.Create(SErrNoFieldsDefined);
|
|
|
|
|
|
+ BindFields(True);
|
|
end;
|
|
end;
|
|
if FAutoIncValue<0 then
|
|
if FAutoIncValue<0 then
|
|
FAutoIncValue:=1;
|
|
FAutoIncValue:=1;
|