File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3861,7 +3861,7 @@ procedure TMainForm.actInsertFilesExecute(Sender: TObject);
38613861procedure TMainForm.actDropObjectsExecute(Sender: TObject);
38623862var
38633863 msg, db: String;
3864- Node: PVirtualNode;
3864+ Node, SiblingDB : PVirtualNode;
38653865 Obj: PDBObject;
38663866 DBObject: TDBObject;
38673867 ObjectList: TDBObjectList;
@@ -3882,7 +3882,15 @@ procedure TMainForm.actDropObjectsExecute(Sender: TObject);
38823882 try
38833883 db := DBObject.Database;
38843884 Node := FindDBNode(DBtree, Conn, db);
3885- SetActiveDatabase('', Conn);
3885+ // Set focus on previous or next database, to prevent "Cannot drop database xyz, because it is currently in use"
3886+ // MS SQL on top cannot "un-use" the current database
3887+ SiblingDB := DBtree.GetNextSibling(Node);
3888+ if not Assigned(SiblingDB) then
3889+ SiblingDB := DBtree.GetPreviousSibling(Node);
3890+ if Assigned(SiblingDB) then
3891+ SetActiveDatabase(DBtree.Text[SiblingDB, 0], Conn)
3892+ else
3893+ SetActiveDatabase('', Conn); // Fallback if there is no sibling. Works on MySQL only.
38863894 Conn.Query(qDatabaseDrop, [Conn.QuoteIdent(db)]);
38873895 DBtree.DeleteNode(Node);
38883896 Conn.ClearDbObjects(db);
You can’t perform that action at this time.
0 commit comments