Find out what database I work with

Posts   
 
    
AlexS
User
Posts: 14
Joined: 18-Apr-2016
# Posted on: 12-Sep-2018 10:05:14   

I am using version 5.4 with SelfServicing Two Classes. I have used the following setting in the config file of my application:


 <sqlServerCatalogNameOverwrites>
    <add key="MyDB" value="MyDB_test"/>
  </sqlServerCatalogNameOverwrites>

 <appSettings>
    <add key="Main.ConnectionString" value="data source=trosqlao;initial catalog=MyDB;persist security info=False;packet size=4096"/>
...

I use these settings to switch between the test database and the production system.

To get the Connectionstring i use:


 CommonDaoBase.ActualConnectionString = SessionController.GetConnectionString();

In SessionController.GetConnectionString i read above setting plus Username an Password.

How can I find out on which database (catalog name) I actually work? The connection string is not suitable because I can overwrite the catalog name in the config file.

I only use one database at a time.

Thanks for your help,

Alex

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 13-Sep-2018 00:00:26   

There is no built-In way to do that. You will need to check the configuration file as follows:

NameValueCollection catalogOverwriteDefinitions = (NameValueCollection)ConfigurationManager.GetSection("sqlServerCatalogNameOverwrites");
if (catalogOverwriteDefinitions != null)
{
    for (int i = 0; i < catalogOverwriteDefinitions.Count; i++)
    {
        string key = catalogOverwriteDefinitions.GetKey(i);
        string value = catalogOverwriteDefinitions.Get(i);
    }
}