View Poll Results: What method do you store connection strings
- Voters
- 3. You may not vote on this poll
-
as a class file
-
in the app.config file
-
March 21st, 2011, 06:54 PM
#1
[RESOLVED] Best Practice/Opinions on Connection String
Just wondering what the general opinion is for storing connections strings in a windows application? As a separate class or in the app.config file?
-
March 21st, 2011, 07:49 PM
#2
Re: Best Practice/Opinions on Connection String
Master DB access isn't necessary, so user ID in config file is usually good enough. User logs in after that
-
March 22nd, 2011, 11:46 PM
#3
Re: Best Practice/Opinions on Connection String
What do you mean by "as a separate class"?
-
March 23rd, 2011, 08:34 AM
#4
Re: Best Practice/Opinions on Connection String
As a completely different class file
-
March 23rd, 2011, 09:17 AM
#5
Re: Best Practice/Opinions on Connection String
Let's clear up something - class has nothing to do with file. You can have multiple classes in one file. You can also use the 'partial' class keyword and have one class span many files. When talking about classes, what file the class resides in is irrelevant (because after compiling the source files are no longer in use).
Are you talking about hardcoding the connection string into a member of the class? If so, this should be avoided.
-
March 28th, 2011, 08:59 AM
#6
Re: Best Practice/Opinions on Connection String
-
March 28th, 2011, 09:07 AM
#7
Re: [RESOLVED] Best Practice/Opinions on Connection String
One last question.
How would I use the app.config file if the location of the DB is dependant on where the application launches.
Example: The application is a portable app designed to be run on a thumb drive.
-
March 28th, 2011, 09:21 AM
#8
Re: [RESOLVED] Best Practice/Opinions on Connection String
 Originally Posted by forgottenhart
How would I use the app.config file if the location of the DB is dependant on where the application launches.
You are better of using some other criteria to determine an app configuration rather than the install location of the app.
For example, if you app launches from the thumb drive, then write a LaunchMode setting in the app.config and set it to ThumbDrive.
There are many ways to accomplish the same thing - basing an app's action on where it's installed from is rarely a good thing.
-
March 28th, 2011, 09:31 AM
#9
Re: [RESOLVED] Best Practice/Opinions on Connection String
Thank you. Is there perhaps a few articles that you can direct me to for some reading/studying.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|