Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
can anyone tell that how can i declare multiple db in single connectionstring in config file.
[FROM OP'S COMMENT]
I Use two Data Base and connection string is
XML
<connectionstrings>
  <add name="ora" connectionstring="Your Path" providername="System.Data.Oracleclient" />
  <add name="sql" connectionstring="Your Path" providername="System.Data.sqlclient" />
</connectionstrings></connectionstrings>

[/FROM OP'S COMMENT]
Posted
Updated 8-Dec-14 1:14am
v2
Comments
Praveen Kumar Upadhyay 8-Dec-14 6:52am    
You can have multiple User key variable(<appsettings> to store different different connection string rather storing it in <connectionstring> section.
Tushar sangani 8-Dec-14 6:59am    
I Use two Data Base and connection string is
<connectionstrings>
<add name="ora" connectionstring="Your Path" providername="System.Data.Oracleclient">
<add name="sql" connectionstring="Your Path" providername="System.Data.sqlclient">
Praveen Kumar Upadhyay 8-Dec-14 7:25am    
Yes this is the way you have to handle it as you have mentioned it in your code.

One connection string can connect you to one database...You can have more than one connection strings to use when fit...
 
Share this answer
 
Multiple databases in one connection string doesn't make programming sense. You will need to declare a connection string for each Database.
You will have to do this like below in your web.config file:
XML
<connectionStrings>
    <add name="DBConnectionString1" connectionString="YourFirstConnectionStringHere" />
    <add name="DBConnectionString2" connectionString="YourSecondConnectionStringHere" />
</connectionStrings>
 
Share this answer
 
You don't specify which database provider you are using, so here is a link where you can find connection string examples to basically any database:
The Connection Strings Reference[^]

It should give you a place to start.
 
Share this answer
 
hi,

try this

XML
<add name="connectionString1" connectionstring="Data Source=DBSERVER;Initial Catalog=DBNAME1;Persist Security Info=True;User ID=sa; password=PASSWORD; Min Pool Size=20; Max Pool Size=6000; Enlist=False;Load Balance Timeout=180" />

<add name="connectionString2" connectionstring="Data Source=DBSERVER;Initial Catalog=DBNAME2;Persist Security Info=True;User ID=sa; password=PASSWORD; Min Pool Size=20; Max Pool Size=1000; Enlist=False;Load Balance Timeout=180" />

   <add name="connectionString3" connectionstring="Data Source=DBSERVER;Initial Catalog=DBNAME3;Persist Security Info=True;User ID=sa; password=PASSWORD; Min Pool Size=20; Max Pool Size=10000; Enlist=False;Load Balance Timeout=180" />




add more connection string
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900