Connection string not readable from web.config?

Last post 11-26-2007 12:19 PM by kckriegs. 1 replies.

Sort Posts:

  • Connection string not readable from web.config?

    11-23-2007, 11:20 PM
    • Loading...
    • iragrollman
    • Joined on 11-11-2007, 10:04 PM
    • Posts 1

    While debugging why a web.config section replacement was not happening in the real web application, I tried a simplified case, no replacement is enabled and the connection string is not showing up?

    Suggestions about what could be happening? The code:

    Dim rootWebConfig As System.Configuration.Configuration

    rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Nothing)

    For Each objConnectionString As System.Configuration.ConnectionStringSettings In _

    rootWebConfig.ConnectionStrings.ConnectionStrings

    lstCS.Items.Add(objConnectionString.Name &
    "|" & objConnectionString.ConnectionString)

    Next 

    Puts "LocalSqlServer|data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true " into the listbox.

    The web.config is:

    <?xml version="1.0"?>

    <configuration>

    <appSettings/>

    <connectionStrings>

    <add name="test" connectionString="placeholder"/>

    </connectionStrings>

    <system.web>

    <compilation defaultLanguage="vb" debug="true"/>

    </system.web>

    </configuration>

    Thanks, Ira

  • Re: Connection string not readable from web.config?

    11-26-2007, 12:19 PM
    Answer
    • Loading...
    • kckriegs
    • Joined on 08-15-2005, 7:55 PM
    • Posts 432

    It is difficult to understand the issue based on your description. Is the listbox populated in your development environment but not on a deployed server? If that's the issue, make sure the application on the deployed server is configured as an ASP.NET 2.0 application, and not ASP.NET 1.1.

Page 1 of 1 (2 items)
Microsoft Communities
Page view counter