/// <summary>
/// This method changes the current database by disconnecting from the actual
/// database and connecting to the specified.
/// </summary>
/// <param name="dbName">The name of the database to use in place of the current database.</param>
public override void ChangeDatabase(String dbName)
{
CheckNotDisposed();
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "ChangeDatabase", dbName);
if (dbName == null)
{
throw new ArgumentNullException("dbName");
}
if (string.IsNullOrEmpty(dbName))
{
throw new ArgumentOutOfRangeException("dbName", dbName, String.Format(resman.GetString("Exception_InvalidDbName")));
}
String oldDatabaseName = Database;
Close();
// Mutating the current `settings` object would invalidate the cached instance, so work on a copy instead.
settings = settings.Clone();
settings[Keywords.Database] = dbName;
_connectionString = null;
Open();
}