I need to have another connection string then the one in machine.config

Discussion in 'ASP .Net' started by Tony Johansson, Jan 4, 2010.

  1. Hello!

    Suppose I need to have a different connectionstring that the one that exist
    in machine.config.

    What is the best practice to do this ?
    Two alternative.
    1. Change in machine.config not so good I suppose.
    2. Create a web.config where you made your modifications.

    I would guess that alternative 2 is the best one.
    One more question. Should the machine.config file never be changed ?

    //Tony
     
    Tony Johansson, Jan 4, 2010
    #1
    1. Advertising

  2. Re: I need to have another connection string then the one inmachine.config

    On Jan 4, 9:17 pm, "Tony Johansson" <>
    wrote:
    > Hello!
    >
    > Suppose I need to have a different connectionstring that the one that exist
    > in machine.config.
    >
    > What is the best practice to do this ?
    > Two alternative.
    > 1. Change in machine.config not so good I suppose.
    > 2. Create a web.config where you made your modifications.
    >
    > I would guess that alternative 2 is the best one.
    > One more question. Should the machine.config file never be changed ?
    >
    > //Tony


    The web.config file is the main configuration file for an ASP.NET web
    application. Use it to store your connectionstring if this is related
    to your single application only. The machine.config is for settings
    that apply to an entire computer. It's located in a system directory
    and normally cannot be changed e.g. on a shared hosting. (On another
    hand because of this, machine.config could be a good idea to secure
    settings).

    Note, web.config has special connectionStrings Element, dedicated for
    this purpose.

    Read more

    connectionStrings Element
    http://msdn.microsoft.com/en-us/library/bf7sd233.aspx

    How to: Read Connection Strings from the Web.config File
    http://msdn.microsoft.com/en-us/library/ms178411.aspx
     
    Alexey Smirnov, Jan 4, 2010
    #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. Nico Grubert
    Replies:
    1
    Views:
    2,617
    Markus Rosenstihl
    Sep 21, 2005
  2. Dan
    Replies:
    4
    Views:
    569
  3. Casey Hawthorne
    Replies:
    3
    Views:
    1,103
    Flash Gordon
    Nov 1, 2009
  4. Replies:
    0
    Views:
    303
  5. Replies:
    4
    Views:
    546
    cwdjrxyz
    Jan 17, 2006
Loading...

Share This Page