none
What is the best place to keep the Connection String

    General discussion

  • Hi all,

    I developed an web application.

    Ealier, I added connection string in the machine.config file.
    Then it was in the registry editor.
    Now it is in my web.config file.

    But still I don't know the real purpose of saving connection string in these places.

    (I mean I know that why it is better to store the connection string in one place rather than keeping it everywhere you need to access. But there should be specific reasons to keep it in the above mentioned places. security, performance, memory allocation etc..)

    Can someone tell me the reason behind this?

    Thanks in advance,

    Jay...


    So Little time; So much to do!
    • Edited by jaywith.7 Tuesday, May 26, 2009 11:08 AM
    Tuesday, May 26, 2009 11:04 AM

All replies

  • The best place to store the connection string in the application configuration file.
    In you case it will be the web.config file.

    Recently i have done a project, for that what i did was.
    During the installation i asked the connection string.
    I have encrypted the connection string and stored it in the web.config file.


    Thanks,
    A.m.a.L
    .Net Goodies
    Remember to click "mark as answered" when you get a correct reply to your question
    Tuesday, May 26, 2009 11:49 AM
  • Hi Amal,

    So, when deploy my application to a seperate server what are the changes I should do?

    Do I have to change the the connection string to some other place?

    Thanks,
    Jay...
    So Little time; So much to do!
    Tuesday, May 26, 2009 1:27 PM
  • While deploying you need to run an installer, rite.

    If you are using Setup & deployment project for creating the installer. You can customize by adding dialog boxes. What i did was, i added one dialog and asked the user to provide database details like, username, password, server, and database names. I internally formed the connection string, stored it in the web.config file.

    Make sure to encrypt the connection string while adding it to the web.config file.

    :)


    Thanks,
    A.m.a.L
    .Net Goodies
    Remember to click "mark as answered" when you get a correct reply to your question
    Tuesday, May 26, 2009 4:37 PM