Browse Source

+ CanModify should return false if the dataset is closed
+ CheckBrowseMode before CanModify at Append
+ Do not call DoInternalClose if an exception is occurred in InternalOpen

git-svn-id: trunk@4494 -

joost 19 years ago
parent
commit
89559ac4ce
2 changed files with 4 additions and 3 deletions
  1. 2 2
      fcl/db/dataset.inc
  2. 2 1
      fcl/db/sqldb/sqldb.pp

+ 2 - 2
fcl/db/dataset.inc

@@ -379,11 +379,11 @@ Procedure TDataset.DoInternalOpen;
 begin
   FDefaultFields:=FieldCount=0;
   DoBeforeOpen;
+  InternalOpen;
   Try
 {$ifdef dsdebug}
     Writeln ('Calling internal open');
 {$endif}
-    InternalOpen;
     FBOF:=True;
 {$ifdef dsdebug}
     Writeln ('Calling RecalcBufListSize');
@@ -1333,9 +1333,9 @@ Procedure TDataset.DoInsertAppend(DoAppend : Boolean);
   end;
 
 begin
+  CheckBrowseMode;
   If Not CanModify then
     DatabaseError(SDatasetReadOnly,Self);
-  CheckBrowseMode;
   DoBeforeInsert;
   DoBeforeScroll;
   If Not DoAppend then

+ 2 - 1
fcl/db/sqldb/sqldb.pp

@@ -1175,7 +1175,8 @@ end;
 Function TSQLQuery.GetCanModify: Boolean;
 
 begin
-  if FCursor.FStatementType = stSelect then
+  // the test for assigned(FCursor) is needed for the case that the dataset isn't opened
+  if assigned(FCursor) and (FCursor.FStatementType = stSelect) then
     Result:= Active and  FUpdateable and (not FReadOnly)
   else
     Result := False;