CODECUBE VENTURES

Getting info from web.config

As opposed to using Application variables or include files to hold data like connection strings, you can use the xml formatted web.config file to hold the info, and retrieving it is quite easy.

By adding a line like this in the appsettings tag under the configuration tag.

<add key="ConnStr" value="DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=c:\mydb\mydb.mdb;User ID=;PassWord=;Persist Security Info=False;" />

Then, retrieving the value is as easy as:

ConfigurationSettings.AppSettings["ConnStr"]

Latest post: Digging Up the First Version of CodeCube

See more in the archives