none
How to retrieve data from two tables using data adapter or data set? RRS feed

  • 問題

  • HI all,

     

    I have a question. Any code samples on retrieve data from two tables using data adapters or data set? I've found on msdn web site that mentioning using two data adapters and add data relations on them. So that they can fill the data set. But it is one to many relations. I want to know that another method on doing this. I know that the two tables with one common field on it.

     

    Thks!

     

    2007年4月3日 上午 04:30

解答

  • HI,

     

    You can let your DataAdapter execute the following SQL Statement:

     

    SELECT Employees.Name, Orders.Product
    FROM Employees
    INNER JOIN Orders
    ON Employees.Employee_ID=Orders.Employee_ID

    then you will get the result of the join of 2 tables in DataSet

     

    tihs

    2007年4月4日 上午 03:26

所有回覆

  • HI,

     

    You can using Query Wizard to join 2 tables when you creating DataAdapter or DataSet, then you got data from 2 tables.

     

    tihs

    2007年4月3日 下午 01:43
  • Yes, thks mr. tihs but how can I do it programmatically. I mean run on the form using code, not using wizard.

     

    2007年4月3日 下午 02:25
  • HI,

     

    You can let your DataAdapter execute the following SQL Statement:

     

    SELECT Employees.Name, Orders.Product
    FROM Employees
    INNER JOIN Orders
    ON Employees.Employee_ID=Orders.Employee_ID

    then you will get the result of the join of 2 tables in DataSet

     

    tihs

    2007年4月4日 上午 03:26