how to use the connection string written in web.config file within .net application 2.0
Posted by in ASP.NET Programming on Dec 21, 2006
  • 0
  • 1
  • 5908
Do you know the answer for this question? Post it below.
Posted by kamal kamal on Dec 22, 2006
  • 0

You write connection string in the web.Config file. Like


<add name="nwindCnn" connectionString="Data Source=Test\SQLEXPRESS;Initial Catalog=NWind;Integrated Security=True"/>


 In program you can use like this

Dim cnn As SqlConnection

cnn = New SqlConnection()

cnn.ConnectionString = ConfigurationManager.ConnectionStrings("nwindCnn").ConnectionString


You can write any number connection strings by giving proper names.