locked
How to store connectionstring in config file RRS feed

  • Question

  • In .net framework 1.x, an sqlconnection object could bind its connectionstring property to a setting in web.config. I can't seem to be able to do the same thing in .net framework 2 (VS 2005).

    I'm guessing that I am missing something obvious here. Can anyone give me a hint?

     

    TF

    Friday, May 26, 2006 9:02 PM

All replies

  • SqlConnection itself won't look in the config files.  Generally, the code that sets the connection string property will do that.

    I don't know the specifics for interacting with web.config, but in V2.0 there is 'System.Configuration.ConfigurationManager.ConnectionStrings["NamedConnectionString"].ConnectionString' that you can use.

    Friday, May 26, 2006 9:41 PM
  • Yes, I know about that syntax and the ability to set it in code. I just think it is strange to remove the possibility to select a key from web.config i design mode if that is what they've done.
    Friday, May 26, 2006 10:21 PM