Connection string not working

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

In VS 2008, I am trying to get my connection from my web.config file but it
is coming up empty.

My code:

Dim ConnectionString As String =
System.Configuration.ConfigurationManager.AppSettings("AssociatesConnectionString")

ConnectionString is nothing after this line.

My web.config has it set as:

<connectionStrings>
<add name="AssociatesConnectionString" connectionString="Data
Source=PTERADON\AW3000_INSTANCE;Initial
Catalog=CSpearAndAssociates;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Why doesn't it pick up this value?

Thanks,

Tom
 
Figured it out.

It needs to be:

System.Configuration.ConfigurationManager.ConnectionStrings("AssociatesConnectionString").ConnectionString

Thanks,

Tom
 
Back
Top