>I have loaded a grid with data from a single table, and would like to know what adaptations are required to use a multi-table join.
>
>What I have is something like this:
>
>
>String query = "select * from Student order by LastName";
>da = new OleDbDataAdapter(query, Cn);
>ds = new DataSet();
>da.Fill(ds, "Student");
>this.dataGrid.DataSource = ds;
>this.dataGrid.DataMember = "Student";
>
>
>Data is stored in Access. I don't think I would have trouble with the JOIN (unless Access syntax is significantly different from Visual FoxPro), but:
>
>What should I replace for "Student" in lines 4 and 6, if the query spans 2 or more tables?
>
>TIA,
>
>Hilmar.
Hilmar,
Probably you wouldn't need a join but separate fills. ie:
da1 = new OleDbDataAdapter(CustomerTablequery, Cn);
da2 = new OleDbDataAdapter(OrdersTablequery, Cn);
da3 = new OleDbDataAdapter(OrdItemsTablequery, Cn);
da1.Fill(ds, "Customer");
da2.Fill(ds, "Orders");
da3.Fill(ds, "OrdItems");
// relations here
this.dataGrid.DataSource = ds;
this.dataGrid.DataMember = "Customer";
This would create a grid with hierarchical style. Or you could create multiple grids:
this.dataGrid1.DataSource = ds;
this.dataGrid1.DataMember = "Customer";
this.dataGrid2.DataSource = ds;
this.dataGrid2.DataMember = "Customer.CustomerOrders"; // relation name
this.dataGrid3.DataSource = ds;
this.dataGrid3.DataMember = "Customer.CustomerOrders.OrdersOrdItems"; // relation name
Cetin