webconfig and database connections

groggy_froggy

Newcomer
Joined
Dec 3, 2004
Messages
2
If I add this code to my page, the database connection works just fine:

Code:
Dim strConnection As String = "server=MYSERVER; database=Northwind; " & _
                                "integrated security=true; connection timeout=30;"

However, if I try to create that connection in the web.config file as:

Code:
<appSettings>
 <add key="NorthWind" value="server=MYSERVER\ASPNET; database=Northwind; integrated security=true;"/>

</appSettings>

...and change the code in my aspx page to:

Code:
Dim strConnection As String = ConfigurationSettings.AppSettings("NorthWind")

the error is:
Code:
  Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

I just don't understand! Why? How?

:confused:
 
Last edited:
Back
Top