in
Forums
Blogs
Files
Devexpress.Com
ClientCenter
Support Center
DevExpress Channel

Binding tables from two different databases

Last post 8/21/2008 8:23 PM by Robert Chaffe. 1 replies.
Page 1 of 1 (2 items)
Sort Posts:
Previous Next
  • 8/21/2008 8:38 AM

    Binding tables from two different databases

     

    Hey guy I need some help in linking two tables from two different databases. My first table its call Work_Order and it comes from and access database, my second table its call Work_Summary and it comes from MSSQL 2005. They are going to be link throw the ID field. I’m going to be showing my data via GridControl. What I’m trying to do is show the Work_Order data and have a plus sign on the left so when they expand the plus sign they will see all the Work_Summary data belonging to that particular Work_Order.

     

    + ID WorkOrder Description…….

    Work_Summary Cost No_Pc……

     

    Any help would be greatly appreciated.

    Thank You Paradise

  • 8/21/2008 8:23 PM In reply to

    Re: Binding tables from two different databases

    Plop a GridControl on a form.
    Set up the initial GridView with GridColumns for the columns you wish to fetch from the Work_Order table.  Include one for the ID field and set its visible property to false if you wish to hide it.
    Add a level to the GridControl.  Change its name from "Level1" to "Orders".
    Add a GridView (or CardView, etc.) to the new level.  This is the detail view.
    Set up the detail view with GridColumns for the columns you wish to fetch from the Work_Summary table.  Include one for the ID field.
     
    In a place suitable for your application, add code to fetch and bind your data.  Something like this, for example (C#):
    _
     
    // Invoke your method for fetching data from the Work_Order table.  See MSDN ADO.NET documentation for DataSet and DataTable, etc.
    // Assuming your method is named FetchWorkOrders and returns a DataTable named "Work_Order" ...
    DataTable workOrderTable = FetchWorkOrders();
     
    // Invoke your method for fetching data from the Work_Summary table.
    // Assuming your method is named FetchWorkSummaries and returns a DataTable named "Work_Summary" ....
    DataTable workSummaryTable = FetchWorkSummaries();
     
    // Create a DataSet and add the two DataTable objects.
    DataSet dataSet = new DataSet();
    dataSet.Tables.Add( workOrderTable );
    dataSet.Tables.Add( workSummaryTable );
    // Set up the relationship, using the same name as the level you created in the grid control.
    // Note that the references to each DataTable by name works if you actually give each DataTable a name!
    dataSet.Relations.Add( "Orders",
        dataSet.Tables[ "Work_Order" ].Columns[ "ID" ],
        dataSet.Tables[ "Work_Summary" ].Columns[ "ID" ] );
    // Bind the data to the grid control.
    DataViewManager dvm = new DataViewManager( dataSet );
    DataView dv = dvm.CreateDataView( dataSet.Tables[ "Work_Order" ] );
    gridControl.DataSource = dv;
    _
     
    Note that there are numerous methodologies for fetching data from each database.  That is not necessarily a Developer Express thing, unless you are using eXpress Persistent Objects, which I have not.  Yet.
     
Page 1 of 1 (2 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED