Friday, 9 July 2010

Connection String

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")

No comments:

Post a Comment