Connection string not working

Discussion in 'ASP .Net' started by tshad, Sep 15, 2008.

  1. tshad

    tshad Guest

    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
     
    tshad, Sep 15, 2008
    #1
    1. Advertising

  2. tshad

    tshad Guest

    Figured it out.

    It needs to be:

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

    Thanks,

    Tom

    "tshad" <> wrote in message
    news:%...
    > 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
    >
    >
     
    tshad, Sep 15, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bernardo Heynemann

    Connection String not working

    Bernardo Heynemann, Dec 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    320
    Bernardo Heynemann
    Dec 27, 2003
  2. John
    Replies:
    3
    Views:
    7,818
    Darkonekt
    Oct 16, 2006
  3. Replies:
    3
    Views:
    852
    Samuel R. Neff
    Aug 3, 2007
  4. DanWeaver
    Replies:
    0
    Views:
    284
    DanWeaver
    Apr 13, 2008
  5. Wei  Lu
    Replies:
    2
    Views:
    5,917
    Wei Lu
    Feb 16, 2009
Loading...

Share This Page