Multiple connection strings

  • Thread starter Thread starter iahmed9060
  • Start date Start date
I

iahmed9060

I am working on a web form using asp.net 2.0. I want to have a
databound dropdownlist control to display 'Company name'.

Here is my problem. I have 2 databases. Database, 'X' and 'Y'.

I am using database 'X' everywhere in the page. But in the 'X' database
I dont have 'company name' it just has 'company ID'. To get 'company
name' I will have to connect to database 'Y' which has both 'Company
ID' and 'Company name' coloumns.

How will I write the sql connectionstring to bind the dropdown control?
So that I can use the Company ID coloumn from 'X' database and match
it with the 'company ID' of 'Y' to display the 'company name' in the
dropdownlist.


Thanks and appreciate the help.

Ahmed
 
I am working on a web form using asp.net 2.0. I want to have a
databound dropdownlist control to display 'Company name'.

Here is my problem. I have 2 databases. Database, 'X' and 'Y'.

I am using database 'X' everywhere in the page. But in the 'X' database
I dont have 'company name' it just has 'company ID'. To get 'company
name' I will have to connect to database 'Y' which has both 'Company
ID' and 'Company name' coloumns.

How will I write the sql connectionstring to bind the dropdown control?
So that I can use the Company ID coloumn from 'X' database and match
it with the 'company ID' of 'Y' to display the 'company name' in the
dropdownlist.

You don't mention what RDBMS it is, so the following is based on three
assumptions:

1) that you're using SQL Server

2) that the two databases are on the same server:

3) SELECT permissions are sufficient

In DatabaseX, run the following:

SELECT * FROM DatabaseY..MyTable

obviously replacing MyTable with the name of an actual table in DatabaseY...
:-)

No need to change the connection string...
 
Yes, Its working..

Thanks..


Mark said:
You don't mention what RDBMS it is, so the following is based on three
assumptions:

1) that you're using SQL Server

2) that the two databases are on the same server:

3) SELECT permissions are sufficient

In DatabaseX, run the following:

SELECT * FROM DatabaseY..MyTable

obviously replacing MyTable with the name of an actual table in DatabaseY...
:-)

No need to change the connection string...
 
Back
Top