Connection string in Web.config

Discussion in 'ASP .Net' started by GaryB, Oct 1, 2004.

  1. GaryB

    GaryB Guest

    In a large asp.net project we have always kept our connection string in the
    Web.config as so....

    <appSettings>
    <!-- User application and configured property settings go here.-->
    <!-- Example: <add key="settingName" value="settingValue"/> -->

    <add key="connCP.ConnectionString" value=" blah, blah, blah......

    When adding and modifying dataadapters in vs.net on a design page we could
    always expand (DynamicProperties) and see our connCP there where we could
    assign it as our connectionstring for the dataadapter. It all worked just
    fine.

    Now, for some reason it's not there anymore. we have to go in and modify
    the standard SQLConnection each time.

    What could have caused this to stop working?

    Thanks,

    G
     
    GaryB, Oct 1, 2004
    #1
    1. Advertising

  2. Hi Gary,

    As for the dynamic properties on those certain Components, that're stored
    in the Application's Config file(web.config for asp.net web application).
    And all the items's values must be retrieved via runtime code. The VS.NET
    IDE only help you generate such code. For example, when we check the
    sqlConnection's connectionstring property to be mapped to a key in the
    web.config, the ide will generate the following code in the webform page's
    initalizecomponent() method:

    ================
    private void InitializeComponent()
    {
    System.Configuration.AppSettingsReader configurationAppSettings = new
    System.Configuration.AppSettingsReader();
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    .............................
    ========================


    So you can have a check to see whether the code is generated correctly. In
    fact, regardless of the vs.net, we can all add the following code ourself.
    And this makes the component's certain dynamic property be intialized by
    the mapped value in the config file.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
    vbtsksettingdynamicproperty.asp

    Hope helps. If you have any other questions, please feel free to post here.
    Thanks.


    Regards,

    Steven Cheng
    Microsoft Online Support
     
    Steven Cheng[MSFT], Oct 4, 2004
    #2
    1. Advertising

  3. GaryB

    GaryB Guest

    Steven,
    Thanks. That clears up the issue. It turns out that our <appsettings
    section of the web.config had become corrupted.
    Gary

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Gary,
    >
    > As for the dynamic properties on those certain Components, that're stored
    > in the Application's Config file(web.config for asp.net web application).
    > And all the items's values must be retrieved via runtime code. The VS.NET
    > IDE only help you generate such code. For example, when we check the
    > sqlConnection's connectionstring property to be mapped to a key in the
    > web.config, the ide will generate the following code in the webform page's
    > initalizecomponent() method:
    >
    > ================
    > private void InitializeComponent()
    > {
    > System.Configuration.AppSettingsReader configurationAppSettings = new
    > System.Configuration.AppSettingsReader();
    > this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    > ............................
    > ========================
    >
    >
    > So you can have a check to see whether the code is generated correctly. In
    > fact, regardless of the vs.net, we can all add the following code ourself.
    > And this makes the component's certain dynamic property be intialized by
    > the mapped value in the config file.
    >
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
    > vbtsksettingdynamicproperty.asp
    >
    > Hope helps. If you have any other questions, please feel free to post
    > here.
    > Thanks.
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
     
    GaryB, Oct 4, 2004
    #3
  4. You're welcome Gary.

    Glad that the problem is got resolved. Have a good day!


    Regards,

    Steven Cheng
    Microsoft Online Support
     
    Steven Cheng[MSFT], Oct 5, 2004
    #4
    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. Michelle A.
    Replies:
    0
    Views:
    570
    Michelle A.
    Aug 20, 2003
  2. Replies:
    4
    Views:
    13,653
  3. Replies:
    0
    Views:
    1,637
  4. CSharpner
    Replies:
    0
    Views:
    1,131
    CSharpner
    Apr 9, 2007
  5. Replies:
    3
    Views:
    864
    Samuel R. Neff
    Aug 3, 2007
Loading...

Share This Page