Question

I'm looking at a custom built .NET control (vb). It has a public string declared as:

Public Shared strConn As String = ConfigurationSettings.AppSettings("TheDB")

I'm trying to find out what "TheDB" is supposed to be exactly. I looked the web.config file of the website using this custom control, but there is no "TheDB" parameter anywhere. I also looked in the web server's machine.config file, and again, no "TheDB" parameters there either.

Help.

Was it helpful?

Solution

If it's missing, just add it:

 <appSettings>
     <add key="TheDB" value="somevalue" />
 </appSettings>

(assuming that ConfigurationSettings.AppSettings really corresponds to appSettings section of the web.config. This is not clear as normally you refer to standard sections of configuration files using builtin ConfigurationManager class)

OTHER TIPS

Look in your web.config. Somewhere in there is a section called "AppSettings", where there should be some elements that look like this:

<add key="TheDB" value="something" />

One of them will be yours. Or possibly somebody took it out. More than likely, though, it's the connection string to your database.

web.config is hierarchical. Each web.config supplies configuration information to the directory in which it is located and to the entire directory hierarchy beneath it.

http://msdn.microsoft.com/en-us/library/ms178685.aspx

Been that way since .Net v1.1. When you look for a configuration value or section, the .Net configuration system looks in the lowest level web.config. If the desired value is not found, it runs up the directory tree until it finds it.

You need to run up the directory hierarchy (and yes, that includes virtual directories mounted in IIS as well) until you find the web.config file containing the desired appsetting value. There is also the IIS ApplicationHost.config as well, located at

%windir%\system32\inetsrv\config
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top