File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3760,7 +3760,7 @@ procedure TMainForm.actInsertFilesExecute(Sender: TObject);
37603760procedure TMainForm.actDropObjectsExecute(Sender: TObject);
37613761var
37623762 msg, db: String;
3763- Node: PVirtualNode;
3763+ Node, SiblingDB : PVirtualNode;
37643764 Obj: PDBObject;
37653765 DBObject: TDBObject;
37663766 ObjectList: TDBObjectList;
@@ -3781,7 +3781,15 @@ procedure TMainForm.actDropObjectsExecute(Sender: TObject);
37813781 try
37823782 db := DBObject.Database;
37833783 Node := FindDBNode(DBtree, Conn, db);
3784- SetActiveDatabase('', Conn);
3784+ // Set focus on previous or next database, to prevent "Cannot drop database xyz, because it is currently in use"
3785+ // MS SQL on top cannot "un-use" the current database
3786+ SiblingDB := DBtree.GetNextSibling(Node);
3787+ if not Assigned(SiblingDB) then
3788+ SiblingDB := DBtree.GetPreviousSibling(Node);
3789+ if Assigned(SiblingDB) then
3790+ SetActiveDatabase(DBtree.Text[SiblingDB, 0], Conn)
3791+ else
3792+ SetActiveDatabase('', Conn); // Fallback if there is no sibling. Works on MySQL only.
37853793 Conn.Query(qDatabaseDrop, [Conn.QuoteIdent(db)]);
37863794 DBtree.DeleteNode(Node);
37873795 Conn.ClearDbObjects(db);
You can’t perform that action at this time.
0 commit comments