DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Reading Web.config / App.config Settings

09.06.2007
| 3610 views |
  • submit to reddit
        // VB.NET 2.0

#If DEBUG Then
    Private Shared _strConnectionString As String = My.Settings.Item("ConnStringDebug")
#Else
    Private shared _strConnectionString As String = My.Settings.Item("ConnString")
#End If


// Web.Config/App.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

	<appSettings>
		<add key="ConnStringDebug" value="Data Source=time01;Initial Catalog=CWBIOSVRdave;UID=sa; PWD=Clockwatch" />
		<add key="ConnString" value="Data Source=time01;Initial Catalog=CWBIOSVRdave;UID=sa; PWD=Clockwatch"/>
	</appSettings>
</configuration>