connection strings in config file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Vmlua2k=?=

    #1

    connection strings in config file

    Hello Everyone,

    I have a question about storing the connection strings to the database
    in a config file or database. My manager wants me to store all the connection
    strings in a database, but I think it is easier and faster to store the
    connection strings in the config file. I was wondering if anyone has any
    opinion on this issue so that I can convince my manager.

    Thanks.
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: connection strings in config file

    Vinki,

    It's definitely a better idea to store your connection strings in the
    config file. If you store them in a database, then how are you supposed to
    connect to the database in the first place to retrieve them? You need to
    have the connection string outside of the database which you are going to
    connect to. The logical place to put that is in the config file.

    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
    news:6BD6C695-0783-4DAF-947C-5231C3061D41@mi crosoft.com...
    Hello Everyone,
    >
    I have a question about storing the connection strings to the database
    in a config file or database. My manager wants me to store all the
    connection
    strings in a database, but I think it is easier and faster to store the
    connection strings in the config file. I was wondering if anyone has any
    opinion on this issue so that I can convince my manager.
    >
    Thanks.

    Comment

    • =?Utf-8?B?Vmlua2k=?=

      #3
      Re: connection strings in config file

      Hi Nicholas,

      Thanks for your response. I conveyed your meesage to the manager and also
      told him that storing them in the database is time taking. He said that
      storing the connection string will not be time taking if we get the
      connection string from the database and store that string in the cache. I am
      not sure what to say about that. I think it is expensive too, but I don't
      have anything to support my views.



      "Nicholas Paldino [.NET/C# MVP]" wrote:
      Vinki,
      >
      It's definitely a better idea to store your connection strings in the
      config file. If you store them in a database, then how are you supposed to
      connect to the database in the first place to retrieve them? You need to
      have the connection string outside of the database which you are going to
      connect to. The logical place to put that is in the config file.
      >
      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m
      >
      "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
      news:6BD6C695-0783-4DAF-947C-5231C3061D41@mi crosoft.com...
      Hello Everyone,

      I have a question about storing the connection strings to the database
      in a config file or database. My manager wants me to store all the
      connection
      strings in a database, but I think it is easier and faster to store the
      connection strings in the config file. I was wondering if anyone has any
      opinion on this issue so that I can convince my manager.

      Thanks.
      >
      >
      >

      Comment

      • Egghead

        #4
        Re: connection strings in config file

        It is a very bad idea to put them into the db. However, I can see a very
        usefully way to do it this way. For instance, I can change the connection
        strings on the fly (fail over). Actually, I will have another class (layer)
        connect to the db and get all the connection string in REAL TIME, without
        letting user doing anythig. Of course, you can hard code that single path
        (web service or db string) in the class or have the string in a config file.
        Remember only one string, NOT "STRINGS".
        Therefore, it is hard to say without knowing all the details.

        --
        cheers,
        RL
        "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c omwrote in
        message news:e79Prvp3HH A.1208@TK2MSFTN GP03.phx.gbl...
        Vinki,
        >
        It's definitely a better idea to store your connection strings in the
        config file. If you store them in a database, then how are you supposed
        to connect to the database in the first place to retrieve them? You need
        to have the connection string outside of the database which you are going
        to connect to. The logical place to put that is in the config file.
        >
        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m
        >
        "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
        news:6BD6C695-0783-4DAF-947C-5231C3061D41@mi crosoft.com...
        >Hello Everyone,
        >>
        > I have a question about storing the connection strings to the database
        >in a config file or database. My manager wants me to store all the
        >connection
        >strings in a database, but I think it is easier and faster to store the
        >connection strings in the config file. I was wondering if anyone has any
        >opinion on this issue so that I can convince my manager.
        >>
        >Thanks.
        >
        >

        Comment

        • Egghead

          #5
          Re: connection strings in config file

          Actually, if the connection strings WILL NEVER CHANGE ONCE DEPOLY, you
          shall do the following test:

          (1) read all the connections from the db (there are time needed for connect
          to the db and running the query) and put them into the cache

          (2) read all the connections from the file and put them into the cache

          (3) hard code the string into the app

          and find out the time different.

          Sorry, where do you learn your programming skill?

          --
          cheers,
          RL
          "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
          news:15967B96-90ED-4287-80B7-E33E6E0478AE@mi crosoft.com...
          Hi Nicholas,
          >
          Thanks for your response. I conveyed your meesage to the manager and also
          told him that storing them in the database is time taking. He said that
          storing the connection string will not be time taking if we get the
          connection string from the database and store that string in the cache. I
          am
          not sure what to say about that. I think it is expensive too, but I don't
          have anything to support my views.
          >
          >
          >
          "Nicholas Paldino [.NET/C# MVP]" wrote:
          >
          >Vinki,
          >>
          > It's definitely a better idea to store your connection strings in the
          >config file. If you store them in a database, then how are you supposed
          >to
          >connect to the database in the first place to retrieve them? You need to
          >have the connection string outside of the database which you are going to
          >connect to. The logical place to put that is in the config file.
          >>
          >--
          > - Nicholas Paldino [.NET/C# MVP]
          > - mvp@spam.guard. caspershouse.co m
          >>
          >"Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
          >news:6BD6C69 5-0783-4DAF-947C-5231C3061D41@mi crosoft.com...
          Hello Everyone,
          >
          I have a question about storing the connection strings to the
          database
          in a config file or database. My manager wants me to store all the
          connection
          strings in a database, but I think it is easier and faster to store the
          connection strings in the config file. I was wondering if anyone has
          any
          opinion on this issue so that I can convince my manager.
          >
          Thanks.
          >>
          >>
          >>

          Comment

          • =?Utf-8?B?Vmlua2k=?=

            #6
            Re: connection strings in config file

            Hi,

            I am not sure why you are saying that it is bad idea to put the connection
            strings in the db. Also, I am not sure why are you saying that where I
            learned the programming from. I mean to say strings to different database not
            string.

            "Egghead" wrote:
            It is a very bad idea to put them into the db. However, I can see a very
            usefully way to do it this way. For instance, I can change the connection
            strings on the fly (fail over). Actually, I will have another class (layer)
            connect to the db and get all the connection string in REAL TIME, without
            letting user doing anythig. Of course, you can hard code that single path
            (web service or db string) in the class or have the string in a config file.
            Remember only one string, NOT "STRINGS".
            Therefore, it is hard to say without knowing all the details.
            >
            --
            cheers,
            RL
            "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c omwrote in
            message news:e79Prvp3HH A.1208@TK2MSFTN GP03.phx.gbl...
            Vinki,

            It's definitely a better idea to store your connection strings in the
            config file. If you store them in a database, then how are you supposed
            to connect to the database in the first place to retrieve them? You need
            to have the connection string outside of the database which you are going
            to connect to. The logical place to put that is in the config file.

            --
            - Nicholas Paldino [.NET/C# MVP]
            - mvp@spam.guard. caspershouse.co m

            "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
            news:6BD6C695-0783-4DAF-947C-5231C3061D41@mi crosoft.com...
            Hello Everyone,
            >
            I have a question about storing the connection strings to the database
            in a config file or database. My manager wants me to store all the
            connection
            strings in a database, but I think it is easier and faster to store the
            connection strings in the config file. I was wondering if anyone has any
            opinion on this issue so that I can convince my manager.
            >
            Thanks.
            >
            >
            >

            Comment

            • Ignacio Machin \( .NET/ C# MVP \)

              #7
              Re: connection strings in config file

              Hi,

              "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
              news:15967B96-90ED-4287-80B7-E33E6E0478AE@mi crosoft.com...
              Hi Nicholas,
              >
              Thanks for your response. I conveyed your meesage to the manager and also
              told him that storing them in the database is time taking. He said that
              storing the connection string will not be time taking if we get the
              connection string from the database and store that string in the cache. I
              am
              not sure what to say about that. I think it is expensive too, but I don't
              have anything to support my views.
              This remember me of a friend of mine, one of his first pet project was an
              app to log in the DB when the DB went offline :)


              Jokes apart, what is his razionale to want the connection strings in the DB?


              Comment

              • Egghead

                #8
                Re: connection strings in config file

                For instance, if that db is offline, what can you do? Or, costs of
                connection time, running the query?
                As I said, it really depend on your design and the system natural.

                --
                cheers,
                RL
                "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
                news:99CC11AB-D874-4200-9C56-A51AF459A3F5@mi crosoft.com...
                Hi,
                >
                I am not sure why you are saying that it is bad idea to put the
                connection
                strings in the db. Also, I am not sure why are you saying that where I
                learned the programming from. I mean to say strings to different database
                not
                string.
                >
                "Egghead" wrote:
                >
                >It is a very bad idea to put them into the db. However, I can see a very
                >usefully way to do it this way. For instance, I can change the connection
                >strings on the fly (fail over). Actually, I will have another class
                >(layer)
                >connect to the db and get all the connection string in REAL TIME, without
                >letting user doing anythig. Of course, you can hard code that single path
                >(web service or db string) in the class or have the string in a config
                >file.
                >Remember only one string, NOT "STRINGS".
                >Therefore, it is hard to say without knowing all the details.
                >>
                >--
                >cheers,
                >RL
                >"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c omwrote
                >in
                >message news:e79Prvp3HH A.1208@TK2MSFTN GP03.phx.gbl...
                Vinki,
                >
                It's definitely a better idea to store your connection strings in
                the
                config file. If you store them in a database, then how are you
                supposed
                to connect to the database in the first place to retrieve them? You
                need
                to have the connection string outside of the database which you are
                going
                to connect to. The logical place to put that is in the config file.
                >
                --
                - Nicholas Paldino [.NET/C# MVP]
                - mvp@spam.guard. caspershouse.co m
                >
                "Vinki" <Vinki@discussi ons.microsoft.c omwrote in message
                news:6BD6C695-0783-4DAF-947C-5231C3061D41@mi crosoft.com...
                >Hello Everyone,
                >>
                > I have a question about storing the connection strings to the
                >database
                >in a config file or database. My manager wants me to store all the
                >connection
                >strings in a database, but I think it is easier and faster to store
                >the
                >connection strings in the config file. I was wondering if anyone has
                >any
                >opinion on this issue so that I can convince my manager.
                >>
                >Thanks.
                >
                >
                >>
                >>
                >>

                Comment

                • John B

                  #9
                  Re: connection strings in config file

                  Vinki wrote:
                  "Nicholas Paldino [.NET/C# MVP]" wrote:
                  >
                  >Vinki,
                  >>
                  > It's definitely a better idea to store your connection strings in the
                  >config file. If you store them in a database, then how are you supposed to
                  >connect to the database in the first place to retrieve them? You need to
                  >have the connection string outside of the database which you are going to
                  >connect to. The logical place to put that is in the config file.
                  >>
                  >--
                  <....>
                  Thanks for your response. I conveyed your meesage to the manager and
                  also
                  told him that storing them in the database is time taking. He said that
                  storing the connection string will not be time taking if we get the
                  connection string from the database and store that string in the
                  cache. I am
                  not sure what to say about that. I think it is expensive too, but I
                  don't
                  have anything to support my views.
                  >
                  Personally I would normally have a singleton configuration class which
                  would load my config from the app.config file or database or both.
                  It wont really matter much where you store the connection strings, so
                  long as you store your initial connection string external to the
                  database and application (please don't hard code it).
                  When your manager says they will be cached, once MSSQL Server reads a
                  "page" from disk, it will not release that page from memory unless that
                  memory is needed elsewhere, this is probably the caching he is referring to.

                  JB

                  Comment

                  • Samuel R. Neff

                    #10
                    Re: connection strings in config file


                    How many connection strings do you have? How often do they change?

                    Normally you only want to store them in a config file because (a) you
                    need a connection string to get to a db in first place, (b) they can
                    be encrypted easily in config file in .net 2.0, and (b) caching is
                    automatic if you use built-in config stuff.

                    Howeve, an app normally has only a few connection strings at most (1
                    is most common I'm sure). So if you have a lot and they change a lot,
                    then it could make sense to store them in the db (updating the config
                    file can cause serious problems in some apps--like if an asp.net app
                    updates web.config, it needs permissions to do so and doing so will
                    trigger a restart of the asp.net app).

                    So in some, I think the answer is still "it depends", and we need more
                    info...

                    HTH,

                    Sam

                    ------------------------------------------------------------
                    We're hiring! B-Line Medical is seeking .NET
                    Developers for exciting positions in medical product
                    development in MD/DC. Work with a variety of technologies
                    in a relaxed team environment. See ads on Dice.com.



                    On Tue, 14 Aug 2007 10:48:07 -0700, Vinki
                    <Vinki@discussi ons.microsoft.c omwrote:
                    >Hello Everyone,
                    >
                    I have a question about storing the connection strings to the database
                    >in a config file or database. My manager wants me to store all the connection
                    >strings in a database, but I think it is easier and faster to store the
                    >connection strings in the config file. I was wondering if anyone has any
                    >opinion on this issue so that I can convince my manager.
                    >
                    >Thanks.

                    Comment

                    Working...