2
0
Эх сурвалжийг харах

* Fix bug ID #29296 (again)

git-svn-id: trunk@33172 -
michael 9 жил өмнө
parent
commit
e88285a257

+ 11 - 9
packages/fcl-db/src/base/bufdataset.pas

@@ -1247,18 +1247,20 @@ begin
   // See mantis #22030
 
   //  if Fields.Count<FieldDefs.Count then
-  if Fields.Count = 0 then
+  if (Fields.Count = 0) or (FieldDefs.Count=0) then
     DatabaseError(SErrNoDataset);
 
-  // If there is a field with FieldNo=0 then the fields are not found to the
-  // FieldDefs which is a sign that there is no dataset created. (Calculated and
-  // lookup fields have FieldNo=-1)
+  // search for autoinc field
   FAutoIncField:=nil;
-  for i := 0 to Fields.Count-1 do
-    if Fields[i].FieldNo=0 then
-      DatabaseError(SErrNoDataset)
-    else if (FAutoIncValue>-1) and (Fields[i] is TAutoIncField) and not assigned(FAutoIncField) then
-      FAutoIncField := TAutoIncField(Fields[i]);
+  if FAutoIncValue>-1 then
+  begin
+    for i := 0 to Fields.Count-1 do
+      if Fields[i] is TAutoIncField then
+      begin
+        FAutoIncField := TAutoIncField(Fields[i]);
+        Break;
+      end;
+  end;
 
   InitDefaultIndexes;
   CalcRecordSize;