1

I am very new to ASP and VB .NET

.aspx file :

   <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConnectionString="<%$ ConnectionStrings:e1ConnectionString %>" 
        ></asp:SqlDataSource>

     <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
     ConnectionString="<%$ ConnectionStrings:e1ConnectionString %>"></asp:SqlDataSource>

code behind .vb file :

Datasource-1 from SQL server instance 1 :

Dim ElcidDwConnectionString As String = "dwstring"
        Dim strConnection1 As String = ConfigurationManager.AppSettings(dwstring).ToString()
        Dim sqlConn1 As SqlConnection = New SqlConnection(strConnection1)
        sqlConn1.Open()
 Dim cmd As New SqlCommand("SELECT SR_number,t1,t2 
        FROM [dw1].[dbo].[StagedServiceRequest]", sqlConn)
        Dim ds As New DataSet
        Dim dataAdapter As SqlDataAdapter = New SqlDataAdapter(cmd)
        dataAdapter.Fill(ds)

Datasource from SQL server intance-2:

SqlDataSource3.SelectCommand = "select SR_NUMBER,address,start_date from [dw2].table2"

I need to join these two data sources on the column SR_NUMBER and Build a table with the data from these two tables on the aspx page. As they are on different server I am assuming the join is not possible with them.

I was using telerik Radgrid, it assumes only a single data source for building the table.But I want the data from data sources on two different instances.

Could some one suggest me a better way of doing this. Like I need to populate the table with the information from both these data sources with or without using telerik Radgrid.

user2569524
  • 1,651
  • 7
  • 32
  • 57

1 Answers1

1

There 2 ways to solve this:

  1. At your code fetch your data from the servers just as you are doing and merge the two datasets, see how to join two datatable datas into one datatable to show in one gridview in asp.net. Basically is:

    DataSet1.Merge(DataSet2)

  2. Use joins at one of your servers (inside an stp or view) and fetch from there, see Selecting data from two different servers in SQL Server

Then is just matter of setting the DataSource property of your GridView or RadGrid.

Community
  • 1
  • 1
roboli
  • 1,418
  • 20
  • 24
  • Merge will actually append the datasets right ? I wish to join my datasets on a key (i mean on a column value). Could you please let me know how can we do that ? – user2569524 Mar 23 '14 at 20:22
  • Say I have Dataset1 and Dataset2 , I want to join them on a field called SRnumber and fetch the additional data from both the tables.] – user2569524 Mar 23 '14 at 20:28
  • 1
    You're right, that will be a merge and not a join. I guess the clearest way will be option 2. But you can use **LINQ** too, i found this [article](http://msdn.microsoft.com/en-us/library/bb386969%28v=vs.110%29.aspx). Hope it helps... – roboli Mar 24 '14 at 02:49
  • Great job putting up more than one option. – DanM7 Sep 26 '14 at 16:12