ConnectionString RRS feed

  • Question

  • Hi

      I was trying to get ConnectionString from App.Config file using

    configuarationManager.ConnectionStrings["Connection"].connectionstring; where in App.config file

    connection string name is Connection. I also added reference to system.configuration. and also added using system.configuration.

    But I am not able to get it. The value is null.I am stuck in going further until I get the answer .

    Thank you all 

    Saturday, January 25, 2014 9:01 PM


  • That code should work. Perhaps you didn't set it up correctly in your app.config. It should look like this:

        <add name="Connection" connectionString="server=MyServer;uid=MyUserName;pwd=MyPassword;database=MyDatabase"/>

    EDIT: One more thing, you should have ConfigurationManager, not configurationManager ... maybe just a typo in your post?

    ~~Bonnie DeWitt [C# MVP]

    Sunday, January 26, 2014 4:26 PM