CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Selecting data from dataset

  1. #1
    Join Date
    Oct 2001
    Posts
    80

    Selecting data from dataset

    Hi,

    Is there a way to select data from 2 tables ( join ) in a dataset?

    I have 1 dataset, filled with two tables that contain data from 2 different servers. Is there a way to do a join select from both, for example "SELECT * FROM ds1.Table[1] inner join ds1.Table[2] on .... "

    Thanks.

  2. #2
    Join Date
    Mar 2006
    Location
    Graz, Austria
    Posts
    273

    Re: Selecting data from dataset

    No, but you can always create a stored procedure with all data you want and have the results in dataset.
    Daniela
    ******
    I would love to change the world, but they won't give me the source code

  3. #3
    Join Date
    Oct 2001
    Posts
    80

    Re: Selecting data from dataset

    That's just the issue. It are two different SQL servers. As far as I know you can't create stored procedures that get data from another server, or am I wrong?

  4. #4
    Join Date
    Apr 2005
    Posts
    576

    Re: Selecting data from dataset

    Well, query in SQL Server can get data from another SQL Server.

    To do it in C# code, you must add a data relation:

    Code:
    ds1.Relations.Add(ds1.Tables[1].Columns[...],ds.Tables[2].Columns[...]);
    and then add columns to the child table

    Code:
    ds1.Tables[2].Columns.Add("NewCol",typeof(string), Parent.ParentCol);
    You can then use the table or define a DataView for the table.

  5. #5
    Join Date
    Mar 2006
    Location
    Graz, Austria
    Posts
    273

    Re: Selecting data from dataset

    You could also use OpenQuery and OpenDatabase functions to get data from another server.

    http://msdn2.microsoft.com/en-us/library/ms188427.aspx
    Daniela
    ******
    I would love to change the world, but they won't give me the source code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)