Same Query - Two Different Data Sources - One GridView - Possible?

Last post 03-12-2007 11:53 PM by Rex Lin - MSFT. 1 replies.

Sort Posts:

  • Same Query - Two Different Data Sources - One GridView - Possible?

    03-12-2007, 5:28 PM

    Hi,
    I have two different Oracle databases, one each for Region A and Region B. Everything else is identical about these databases except their name. What I'm trying achieve is, to run the same query on these two databases and use the results from each to populate a single Datagrid. Is this possible? FWIW, I'm using Data Access Application Block for all data access.

    An example query would be something like this:

     

      
    SELECT ColumnA, ColumnB FROM (RegionA_DB's TableA)
    SELECT ColumnA, ColumnB FROM (RegionB_DB's TableA)
     although it may not be this simple as the connection string is different for both DBs. AIso, UNION doesn't seem possible here, but please correct me if it is.

     Thank you.

  • Re: Same Query - Two Different Data Sources - One GridView - Possible?

    03-12-2007, 11:53 PM
    Answer

    Dear, friend:

    You can get the dataTable from the two DataSource and merge them into a new one:

    Dim dt As New DataTable("dt")
    dt.Columns.Add("1")
    dt.Columns.Add("2")
    dt.Columns.Add("3")

    Dim dr As DataRow
    dr = dt.NewRow
    dr("1") = "11"
    dr("2") = "21"
    dr("3") = "31"
    dt.Rows.Add(dr)

    Dim dt2 As New DataTable("dt")
    dt2.Columns.Add("1")
    dt2.Columns.Add("2")
    dt2.Columns.Add("3")

    dr = dt2.NewRow
    dr("1") = "12"
    dr("2") = "22"
    dr("3") = "32"
    dt2.Rows.Add(dr)

    Dim ds As New DataSet
    ds.Tables.Add(dt)
    ds.Merge(dt2)

    'note that both tables have the same name and columns
    'this does put both sets of data into the datatable in the dataset

    If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved and we will look into it again

    Best Regards,
    __________________________________________________
    Sincerely,
    Rex Lin
    Microsoft Online Community Support

    If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter