Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Connection String in Properties.Settings

Connection String in Properties.Settings

Scheduled Pinned Locked Moved C#
databasequestioncsharpdata-structureshelp
20 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P PIEBALDconsult

    I don't know that the file should be stored in the user's documents directory, it doesn't sound like the right place. I think a better place is APPDATA (APPDATA=C:\Users\Xxxxx\AppData\Roaming), then you can refer to it as @"%APPDATA%\dbs\latefee.sdf" and then use System.Environment.ExpandEnvironmentVariables before opening it. It's olde school, like me. :cool:

    T Offline
    T Offline
    TheJudeDude
    wrote on last edited by
    #8

    Thank you all for dropping all this knowledge on me. It's been a while since I have done any coding, and I am not a programmer by trade. I am in IT for the company I work for, doing mostly tech work (very small business). I write small desktop apps for reporting from our POS system and use C# as I understood it most with VS 2003 (.net 1.1). As I saw a need to update from XP to Win 7, I am trying to rewrite these programs with .net 4, so I am just now, as a few days ago, trying to learn the new IDE in VS 2010, the new classes and deprecated classes, etc, etc. Thank you for your understanding and patience. Trying to google and study everything while taking calls all day for every problem from 'the internet is down' to 'this document is not printing correctly' is quite a task. Again, thanks!

    Jude

    1 Reply Last reply
    0
    • P PIEBALDconsult

      Oh, get off the Replace kick! :-D Possibly use an environment variable and let the system do the replace. But I suspect that the poster doesn't actually want to use the settings file at all. I'd write my own config file. :shrug:

      S Offline
      S Offline
      SledgeHammer01
      wrote on last edited by
      #9

      So, you want the system to do a simple literal replace for you, but you want to roll your own config file implementation? Clever :doh:. Are you also going to write all the cool stuff that you get for free with config files such as encryption, versioning, editing through a simple GUI in VS, backwards compatibility, etc?

      P 1 Reply Last reply
      0
      • S SledgeHammer01

        So, you want the system to do a simple literal replace for you, but you want to roll your own config file implementation? Clever :doh:. Are you also going to write all the cool stuff that you get for free with config files such as encryption, versioning, editing through a simple GUI in VS, backwards compatibility, etc?

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #10

        Yes.

        S 1 Reply Last reply
        0
        • P PIEBALDconsult

          Yes.

          S Offline
          S Offline
          SledgeHammer01
          wrote on last edited by
          #11

          Why?

          P 1 Reply Last reply
          0
          • S SledgeHammer01

            Why?

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #12

            Control.

            S 1 Reply Last reply
            0
            • P PIEBALDconsult

              Control.

              S Offline
              S Offline
              SledgeHammer01
              wrote on last edited by
              #13

              LOL. You mean so you can impose your crazy formatting on it? :-D

              P 1 Reply Last reply
              0
              • S SledgeHammer01

                LOL. You mean so you can impose your crazy formatting on it? :-D

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #14

                Maaaybeee...

                S 1 Reply Last reply
                0
                • P PIEBALDconsult

                  Maaaybeee...

                  S Offline
                  S Offline
                  SledgeHammer01
                  wrote on last edited by
                  #15

                  Neato. How do you integrate with the Visual Studio designer? You should totally write an article about that aspect of it.

                  J 1 Reply Last reply
                  0
                  • S SledgeHammer01

                    Neato. How do you integrate with the Visual Studio designer? You should totally write an article about that aspect of it.

                    J Offline
                    J Offline
                    jschell
                    wrote on last edited by
                    #16

                    SledgeHammer01 wrote:

                    How do you integrate with the Visual Studio designer?

                    Configuration files via the designer? Myself I absolutely despise that. Every time you touch it it re-writes the file. Which means that all formatting is lost. And all documentation. So you have a file that is intended to be manually edited not using VS which has no formatting and no documentation. And which isn't even necessarily guaranteed the have the same ordering between point releases. So an absolute mess.

                    S 1 Reply Last reply
                    0
                    • J jschell

                      SledgeHammer01 wrote:

                      How do you integrate with the Visual Studio designer?

                      Configuration files via the designer? Myself I absolutely despise that. Every time you touch it it re-writes the file. Which means that all formatting is lost. And all documentation. So you have a file that is intended to be manually edited not using VS which has no formatting and no documentation. And which isn't even necessarily guaranteed the have the same ordering between point releases. So an absolute mess.

                      S Offline
                      S Offline
                      SledgeHammer01
                      wrote on last edited by
                      #17

                      jschell wrote:

                      Every time you touch it it re-writes the file

                      Yes, it does.

                      jschell wrote:

                      Which means that all formatting is lost.

                      It does mess up the formatting, I'll agree with that. Since it's an XML file, I just hit the "Format Document" button and it fixes it. Not enough of an annoyance to give up the designer editor IMO.

                      jschell wrote:

                      And all documentation.

                      You put documentation in your config file? Thats an extremely odd place for documentation seeing as the .config files are NOT meant to be edited manually by end users. They are meant to be edited by people who know what the settings are (i.e. developers, etc).

                      jschell wrote:

                      guaranteed the have the same ordering between point releases

                      Last time I checked, XML and .config files were unordered formats. If you are relying on the order of tags in an XML and/or .config file... "ur doin' it wrong".

                      J 1 Reply Last reply
                      0
                      • S SledgeHammer01

                        jschell wrote:

                        Every time you touch it it re-writes the file

                        Yes, it does.

                        jschell wrote:

                        Which means that all formatting is lost.

                        It does mess up the formatting, I'll agree with that. Since it's an XML file, I just hit the "Format Document" button and it fixes it. Not enough of an annoyance to give up the designer editor IMO.

                        jschell wrote:

                        And all documentation.

                        You put documentation in your config file? Thats an extremely odd place for documentation seeing as the .config files are NOT meant to be edited manually by end users. They are meant to be edited by people who know what the settings are (i.e. developers, etc).

                        jschell wrote:

                        guaranteed the have the same ordering between point releases

                        Last time I checked, XML and .config files were unordered formats. If you are relying on the order of tags in an XML and/or .config file... "ur doin' it wrong".

                        J Offline
                        J Offline
                        jschell
                        wrote on last edited by
                        #18

                        SledgeHammer01 wrote:

                        You put documentation in your config file? Thats an extremely odd place for documentation seeing as the .config files are NOT meant to be edited manually by end users. They are meant to be edited by people who know what the settings are (i.e. developers, etc).

                        No idea what kind of "end users" you have but my end users are Operations and Support personnel. And they are specifically the people that need to edit the configuration values. Also no idea how you release software but busienss needs often drive new feature releases along, of course with bug fixes. And those can all require configuration values. So changes happen frequently. Also although it might be nice to have a formal operations manual actually producing that seems to be a problem at most places I work at. And configuration files that have more than just a couple entries require documentation. Which either means putting it in the configuration file or putting it in another file. If it is put in another file then Operations/Support must be told about it. Repeatedly. And of course to create a actual operations manual means that I, and no one else, would need to produce the documentation in the first place. Far as I am concerned since I know Operations/Support will be looking to the file anyways the documentation that is in there is going to be the source for the formal document anyways.

                        SledgeHammer01 wrote:

                        Last time I checked, XML and .config files were unordered formats.

                        Both of those are entirely incorrect. XML can be unordered or ordered. And MS config files have some sections that require specific ordering. But that doesn't have anything to do with what I am talking about...

                        SledgeHammer01 wrote:

                        If you are relying on the order of tags in an XML and/or .config file... "ur doin' it wrong".

                        If if fact that had anything to do with delivering a configuration file then you would in fact be correct. But it doesn't. The order however does matter when Operations/Support uses standard difference tools to compare configuration files. Such as what they might do when they need to install a new major version or point release and they want to insure production machines have the same values with a new configuration file and the old one.

                        S 1 Reply Last reply
                        0
                        • J jschell

                          SledgeHammer01 wrote:

                          You put documentation in your config file? Thats an extremely odd place for documentation seeing as the .config files are NOT meant to be edited manually by end users. They are meant to be edited by people who know what the settings are (i.e. developers, etc).

                          No idea what kind of "end users" you have but my end users are Operations and Support personnel. And they are specifically the people that need to edit the configuration values. Also no idea how you release software but busienss needs often drive new feature releases along, of course with bug fixes. And those can all require configuration values. So changes happen frequently. Also although it might be nice to have a formal operations manual actually producing that seems to be a problem at most places I work at. And configuration files that have more than just a couple entries require documentation. Which either means putting it in the configuration file or putting it in another file. If it is put in another file then Operations/Support must be told about it. Repeatedly. And of course to create a actual operations manual means that I, and no one else, would need to produce the documentation in the first place. Far as I am concerned since I know Operations/Support will be looking to the file anyways the documentation that is in there is going to be the source for the formal document anyways.

                          SledgeHammer01 wrote:

                          Last time I checked, XML and .config files were unordered formats.

                          Both of those are entirely incorrect. XML can be unordered or ordered. And MS config files have some sections that require specific ordering. But that doesn't have anything to do with what I am talking about...

                          SledgeHammer01 wrote:

                          If you are relying on the order of tags in an XML and/or .config file... "ur doin' it wrong".

                          If if fact that had anything to do with delivering a configuration file then you would in fact be correct. But it doesn't. The order however does matter when Operations/Support uses standard difference tools to compare configuration files. Such as what they might do when they need to install a new major version or point release and they want to insure production machines have the same values with a new configuration file and the old one.

                          S Offline
                          S Offline
                          SledgeHammer01
                          wrote on last edited by
                          #19

                          jschell wrote:

                          No idea what kind of "end users" you have but my end users are Operations and Support personnel. And they are specifically the people that need to edit the configuration values.

                          Same kind. I've noticed they are often too retarded to manually edit config files, so I usually provide an easy to use GUI for them (or at the very least, send them a whole new config file they just replace the old one with). For applications that go out to end users, asking an end user to change a config file is asking for trouble. Your GUI should do all that. I know where you're going next... web.configs, web services, etc. don't have GUIs. Well, for a production application, I usually have an admin app or admin portal that controls the system. Much better design. Also, if you want a simple generic thing, you could do what I did. Have a simple property grid dialog that edits any config file generically and can pull in "documentation" either from an xml file or reflection.

                          jschell wrote:

                          XML can be unordered or ordered.

                          Entirely incorrect. The XML spec says specifically that attributes and siblings are unordered and can be returned in any order the parser wants. It just so happens that every parser returns siblings and attributes in document order, but that is NOT guaranteed. If you are relying on something that the XML spec says specifically is not guaranteed, I'd hate to be you when your ops team deploys "XML v17" which has some awesome performance optimization, but no longer returns in doc order and breaks all your stuff. The proper way to do ordering in an XML file is by using a key. I will admit however, that it's unlikely that a parser will start returning stuff in non document order, simply because some apps rely on that incorrectly.

                          jschell wrote:

                          The order however does matter when Operations/Support uses standard difference tools to compare configuration files. Such as what they might do when they need to install a new major version or point release and they want to insure production machines have the same values with a new configuration file and the old one.

                          What does this have to do with anything? .NET has this cool versioning thing that automagically updates your config files for you and adds in any missing attributes. Yes, I'll admit that the missing attributes may be added in a different order

                          J 1 Reply Last reply
                          0
                          • S SledgeHammer01

                            jschell wrote:

                            No idea what kind of "end users" you have but my end users are Operations and Support personnel. And they are specifically the people that need to edit the configuration values.

                            Same kind. I've noticed they are often too retarded to manually edit config files, so I usually provide an easy to use GUI for them (or at the very least, send them a whole new config file they just replace the old one with). For applications that go out to end users, asking an end user to change a config file is asking for trouble. Your GUI should do all that. I know where you're going next... web.configs, web services, etc. don't have GUIs. Well, for a production application, I usually have an admin app or admin portal that controls the system. Much better design. Also, if you want a simple generic thing, you could do what I did. Have a simple property grid dialog that edits any config file generically and can pull in "documentation" either from an xml file or reflection.

                            jschell wrote:

                            XML can be unordered or ordered.

                            Entirely incorrect. The XML spec says specifically that attributes and siblings are unordered and can be returned in any order the parser wants. It just so happens that every parser returns siblings and attributes in document order, but that is NOT guaranteed. If you are relying on something that the XML spec says specifically is not guaranteed, I'd hate to be you when your ops team deploys "XML v17" which has some awesome performance optimization, but no longer returns in doc order and breaks all your stuff. The proper way to do ordering in an XML file is by using a key. I will admit however, that it's unlikely that a parser will start returning stuff in non document order, simply because some apps rely on that incorrectly.

                            jschell wrote:

                            The order however does matter when Operations/Support uses standard difference tools to compare configuration files. Such as what they might do when they need to install a new major version or point release and they want to insure production machines have the same values with a new configuration file and the old one.

                            What does this have to do with anything? .NET has this cool versioning thing that automagically updates your config files for you and adds in any missing attributes. Yes, I'll admit that the missing attributes may be added in a different order

                            J Offline
                            J Offline
                            jschell
                            wrote on last edited by
                            #20

                            SledgeHammer01 wrote:

                            Much better design.

                            Nonsense.

                            SledgeHammer01 wrote:

                            so I usually provide an easy to use GUI for them

                            Which means you must STILL provide documentation. And a GUI. So now you have increased the work and time to deliver.

                            SledgeHammer01 wrote:

                            I know where you're going next... web.configs, web services, etc. don't have GUIs

                            So you create a GUI, and documentation for the GUI that handles multiple versions for a process that Operations/Support only uses once per install. Thus quite a bit of additional time and cost - which is your rationalization for ignoring the fact that it rewrites the file?

                            SledgeHammer01 wrote:

                            Entirely incorrect.

                            Something new for you to learn... http://www.w3schools.com/schema/el_sequence.asp[^] See the first example which says "which must contain the following five elements in order"

                            SledgeHammer01 wrote:

                            which has some awesome performance optimization,

                            Yes the high volume tps servers that I have been delivering for the past 15 years do have measured and proven production performance abilities.

                            SledgeHammer01 wrote:

                            The proper way to do ordering in an XML file is by using a key.

                            The proper way is to understand more about what "XML" means.

                            SledgeHammer01 wrote:

                            What does this have to do with anything?

                            What it has to do with is documentation. Please read what I said. Trivial applications might have config values that are understood without documentation but more complex apps require substantial documentation so someone besides the original developer has any chance of understanding what the values mean, how they should be set, what the relationship between different values, etc.

                            SledgeHammer01 wrote:

                            ...and having a non standard API, but thats just me.

                            Yes it is you, because I didn't say anything like that.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups