Multiple connection strings

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
 
M

Mark Rae

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...
 
I

iahmed9060

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top