简体   繁体   English

SQL Server 2005中的连接字符串可以从文件中获取吗?

[英]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. 作为实习的一部分,我已经为一家公司创建了一个支持Web的数据库 ,并且已经准备就绪。 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. 但是IT人士说他希望我包含各种连接字符串的文件读取连接字符串,然后选择当时想要的任何一个。

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 感谢Sujit的期待

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). 这很常见,以至于.NET中配置文件架构已经有一个用于连接字符串的位置(以及用于对该部分进行加密的机制)。

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. 当您指示正在使用.NET时,应查看app.config文件,尤其是ConfigurationManangerConnectionStrings部分/属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM