2 Database on hosted in different different servers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vivektyagi14
    New Member
    • Nov 2014
    • 1

    2 Database on hosted in different different servers

    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 connectionstrin g in C#.

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

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

    Thanks
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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

    Comment

    • robherr
      New Member
      • Sep 2014
      • 9

      #3
      I haven't encountered this setup and from the looks of it I may say it's impossible.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        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

        Comment

        Working...