diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 14c7f790..2a54f4b7 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -3555,6 +3555,13 @@ begin Query(GetSQLSpecifity(spUSEQuery, [s]), False); // FDatabase is set via DetectUSEQuery end; + + // Save last used database in session, see #983 + if not FParameters.SessionName.IsEmpty then begin + AppSettings.SessionPath := FParameters.SessionPath; + AppSettings.WriteString(asLastUsedDB, Value); + end; + if Assigned(FOnObjectnamesChanged) then FOnObjectnamesChanged(Self, FDatabase); end; diff --git a/source/main.pas b/source/main.pas index fb9b6886..15d74222 100644 --- a/source/main.pas +++ b/source/main.pas @@ -2457,8 +2457,6 @@ begin RefreshHelperNode(HELPERNODE_COLUMNS); // Last chance to access connection related properties before disconnecting - AppSettings.SessionPath := Item.Parameters.SessionPath; - AppSettings.WriteString(asLastUsedDB, Item.Database); // Disconnect Item.Active := False;