Question: I have my SQL Server connection string set up like this: 

```
String strConnection = @"Data Source=servername;Initial Catalog=dbname; User ID =user; Password =pass;";

```

Then I have a combobox which shows all tables in that database. Connection string works fine with one database (initial catalog). But what if I want to pull tables from 2 databases on the same server. User in SQL Server has access to both databases. What connection string do I use then? 

The easy way would be `Initial Catalog=dbname,db2name`. But that does not work of course.

Answer: 
If that user does have in fact permissions to access the other database - you could just simply use the `ChangeDatabase` method on your `SqlConnection` - like this:

```
string strConnection = @"Data Source=servername;Initial Catalog=dbname; User ID =user; Password =pass;";

using (SqlConnection conn = new SqlConnection(strConnection))
{
     // do what you want to do with "dbname"
     ......

     // switch to "db2name" - on the same server, with the same credentials 
     conn.ChangeDatabase("db2name");

     // do what you want to do with "db2name"
     ......
}

```
Edit Start

1) If you want to show all the tables in all the data bases please populate the combo box the same.
refer: [How do I list all tables in all databases in SQL Server in a single result set?](https://stackoverflow.com/questions/2875768/how-do-i-list-all-tables-in-all-databases-in-sql-server-in-a-single-result-set)

2) Or you can provide another combo box to display list of data bases, prior to tables combo box, once user chooses a DB name, pass it to the query. This is useful choice, as there is a possibility of having a table with same name in two data bases. (Eg: t\_users in db\_1 and db\_2)

3) If you have confined to two data bases, use where clause in the above said (1)

Edit end

If you want to access multiple data bases of one server and one instance, It is enough to have one connection to one database in that server and instance, provided user has access to those DBs. You can query any data base if all DB are in same server and instance, see example below.

```
SELECT a.ID, b.ID
FROM Database1.dbo.table1 a
INNER JOIN Database2.dbo.table2 b on a.ID = b.ID

```

In your case, you can have your query of stored procedure similar to below queries.

```
select * 
from sys.tables --to fetch list of tables from the DB which you app connected to 

select * 
from IAMS_Discr_Complaints.sys.tables --to fetch tables from another DB on the same server

```