can connection string in SQL Server 2005 be taken from a file?
I have created a web enabled DB for a company as a part of my internship and it's up and ready. However the connection string of the server is already coded by me. But the IT guy said that he wanted me to read the connection string from a file containing various connection strings and choosing whichever it wanted to at that time.
My question is, Is it possible???....If Yes How???
Kindly help me...i had a long se开发者_运维问答ssion with him trying to understand the concept, still could'nt get it.
Thanking in anticipation Sujit
How to: Read Connection Strings from the Web.config File
This shouldn't be a problem.
Put the connection string in a file, read the file in your program and pass the string in to the database connection object you are using.
This is so common that in .NET the configuration file schema already has a place for connection strings (plus mechanisms to encrypt that section).
Update:
As you indicate that you are using .NET, you should look into the app.config
file, in particular the ConfigurationMananger
and the ConnectionStrings
section/property.
精彩评论