If you are talking about a
connection string, then you cannot connect to two databases with one connection string. A connection string is made up of following things.
- Server name -- The database server
- Database name -- The name of the database you're connecting to
- ... Other authentication settings
This makes up your connection string. So, once you will enter a
name of database you will ensure that you want to connect to a particular
database instance. How would this connect to two separate databases?
It cannot...
However... There is another turn around, in which even if you are connected to a single instance. You can still connect to other databases, think of the following line,
[DbName].dbo.[TableName]
It uses full name for a database and table. Now when you will write this object in your SQL statement. It would not simply just check inside your own database (
that you are connected to using that connection string) but instead it would ask your server to return the response for that database's table. So this can be usable if you want to use other database instances while using connection string for one database.
But this does not mean that you are now connected to other databases also.
So in your sections, you can maintain a single object for retrieving the data. This is why using a Model is always considered good practice (IMO). Your model would contain all of the connections, data types and other objects for your database (
Ever worked with Entity framework?). Which you can then use by calling instance or static members of this "Model" class.