CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Wednesday, April 11, 2007

Writing connection string in web.config in .NET 1.1 and .NET 2.0

Asp.net 2.0

<connectionStrings>
<
add name="ConnString" connectionString="Data Source=ServerName;Initial Catalog=DBNAME;Integrated Security=True;" providerName="System.Data.SqlClient"/>
connectionStrings>

Code Behind

Dim con As String = System.Configuration.ConfigurationManager.ConnectionStrings("ConnString").ConnectionString

Asp.net 1.1

<appSettings>
<add key="ConnString" value="Data Source=ServerName;Initial Catalog=DBNAME;Integrated Security=True;" providerName="System.Data.SqlClient"/>
appSettings>

Code Behind:
Dim con2 As String = System.Configuration.ConfigurationSettings.AppSettings("ConnString")

Post a Comment