Getting value of defaultDatabase from app config

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi! I can not seem to figure out how to get the value of the defaultDatabase
<dataConfiguration defaultDatabase="mydb"/>
from the app config file.

This does not work because the entry is not in the <appSettings>:

ConfigurationManager.AppSettings["defaultDatabase"]

What are my options? It seems to be so trivial yet....

Many thanks in advance,
 
Hi! I can not seem to figure out how to get the value of the defaultDatabase
<dataConfiguration defaultDatabase="mydb"/>
from the app config file.

This does not work because the entry is not in the <appSettings>:

ConfigurationManager.AppSettings["defaultDatabase"]

What are my options? It seems to be so trivial yet....

Many thanks in advance,

You can add it to the connectionStrings section...

string connectionString = ConfigurationManager.ConnectionStrings["defaultDatabase"].ConnectionString;
 
Back
Top