S_anand
S_anand

Reputation: 141

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 session with him trying to understand the concept, still could'nt get it.

Thanking in anticipation Sujit

Upvotes: 0

Views: 105

Answers (2)

Oded
Oded

Reputation: 499012

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.

Upvotes: 1

Related Questions