How can I access multiple databases in a single project for inserting data at the same time? Is it possible to use different connection strings in a single web.config
file?
Yes it is possible.Use connectionStrings section in web.config
<connectionStrings>
<add name="connection1" connectionString="Your Connection string" providerName="Your provider name"/>
<add name="connection2" connectionString="Your Connection string" providerName="Your provider name"/>
<add name="connection3" connectionString="Your Connection string" providerName="Your provider name"/>
</connectionStrings>
use this connection string in your project as
ConfigurationManager.ConnectionStrings["Your connection string name"].ToString()
Yes you can,
By adding many connection strings in your web.config file
As:
<connectionStrings>
<add name="connection1" connectionString="First Connection string" providerName="Your provider name"/>
<add name="connection2" connectionString="Second Connection string" providerName="Your provider name"/>
</connectionStrings>
and in your code, you can call wich connection String you want as:
ConfigurationManager.ConnectionStrings["First Connection string"].ToString()
or
ConfigurationManager.ConnectionStrings["Second Connection string"].ToString()
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.