简体   繁体   中英

can i have two connection string in two different web config in one asp.net project

can i have two different connection string in two different web config file in same web asp.net application?

I know that one asp.net project can have two web.config file in different directory of the project, But I want to add one connection string in one config file and another connection string in another config file in the same asp.net projcet

Yes this is possible.

If the connection strings have the same "name", then the one in the directory will override the one in the root folder.

See this article for more information on web.config hierarchy:

http://msdn.microsoft.com/en-us/library/ms178685.aspx

Yes you can do it !

You can keep different names for connection string. You have to make sure that you are not overriding the connection string by keeping the same names.

<connectionStrings>

<add name="Test" connectionString="DataSource=MyDataSource;Initial     
   Catalog=MC1;User ID=Test; Password=Demo;" />
<add name="Test1" connectionString="Data Source=MyDataSource;Initial 
   Catalog=MC2;User ID=Test1; Password=Demo;" />

<connectionStrings>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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