By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

2 Database on hosted in different different servers

P: 1
I have 2 databases. These are host on different different servers. I want to join the tables of those databases.
here..(1) UserId is same in both database table
(2) Table name are TB1 and TB2
(3) Database are DB1 and DB2

i want to bind the data in a gridview from both database's tables.

Note 1 :-Is this possible to get both tables data from a single connectionstring in C#.

Note 2 :- is this possible that 2 connectionstring call in a single SQLConnection Con = new SQLConnection(.....).

Please help me and send me Query. as soon as possible.

Thanks
Nov 19 '14 #1
Share this Question
Share on Google+
3 Replies


Frinavale
Expert Mod 5K+
P: 9,731
No it is not possible to use the same connection string to connect to 2 different databases. The connection string is unique to the database that the connection is meant to utilize.

However, it is possible to fill tables within an in-memory DataSet with data from multiple databases.

You can bind your GridView to the DataSet containing the information.

-Frinny
Nov 19 '14 #2

P: 9
I haven't encountered this setup and from the looks of it I may say it's impossible.
Nov 26 '14 #3

Frinavale
Expert Mod 5K+
P: 9,731
It isn't impossible to bind a GridView to a data source that contains data that is retrieved from multiple databases or other sources.

You would just retrieve the data from data source A and store that information into an in-memory data cache (like a DataSet or DataTable) and then you would retrieve more data from source B and also store that information into the in-memory data cache. It's pretty straightforward.

It is impossible to use the same connection to retrieve the data from multiple data sources though. I mean, you could re-use the objects but the connection parameters and commands would have to be changed to match the source that it is connecting to.

-Frinny
Nov 26 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.