473,385 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.
Aug 14 '07 #1
9 2751
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]
- mv*@spam.guard.caspershouse.com

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:6B**********************************@microsof t.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.

Aug 14 '07 #2
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]
- mv*@spam.guard.caspershouse.com

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:6B**********************************@microsof t.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.


Aug 14 '07 #3
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]" <mv*@spam.guard.caspershouse.comwrote in
message news:e7**************@TK2MSFTNGP03.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]
- mv*@spam.guard.caspershouse.com

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:6B**********************************@microsof t.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.


Aug 14 '07 #4
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" <Vi***@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.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]
- mv*@spam.guard.caspershouse.com

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:6B**********************************@microso ft.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.



Aug 14 '07 #5
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]" <mv*@spam.guard.caspershouse.comwrote in
message news:e7**************@TK2MSFTNGP03.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]
- mv*@spam.guard.caspershouse.com

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:6B**********************************@microsof t.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.


Aug 14 '07 #6
Hi,

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.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?
Aug 14 '07 #7
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" <Vi***@discussions.microsoft.comwrote in message
news:99**********************************@microsof t.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]" <mv*@spam.guard.caspershouse.comwrote
in
message news:e7**************@TK2MSFTNGP03.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]
- mv*@spam.guard.caspershouse.com

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:6B**********************************@microsof t.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.




Aug 14 '07 #8
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
Aug 14 '07 #9

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
<Vi***@discussions.microsoft.comwrote:
>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.
Aug 15 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Gary Brizard | last post by:
OK. For an n-tier architecture, where is the best place to store the connection string for the DA layer? I don't want to use the reg. Can't use a app.config for a dll. For other projects I...
14
by: WebMatrix | last post by:
Hello, I have developed a web application that connects to 2 different database servers. The connection strings with db username + password are stored in web.config file. After a code review,...
4
by: Dave | last post by:
We store all of our connection strings in the root web.config. I have a connection string called connectionString1 stored in the web.config file at wwwroot. I can get to this through code no...
4
by: Matt Colegrove | last post by:
I'm working on a web app that is published to a hosting service. I'm developing it on my local PC with VS 2005 and SQL Express. The hosting service DB is SQL Server 2000. I have two...
5
by: Matt | last post by:
Hello, What is the best way to handle the database connection string for a class library project that will be compiled and used as a .dll? This .dll will be accessed via classic ASP and in...
37
by: sam44 | last post by:
Hi, At startup the user log on and chooses the name of a client from a dropdownlist, which then changes dynamically the connection string (the name of the client indicates which database to use)....
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.