Getting value of defaultDatabase from app config

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,
 
T

Tom Shelton

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top