Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is an example from one of my classes</p> <pre><code>// create the relationship between Booking and Booking_MNI DataRelation relBookingMNI; relBookingMNI = new DataRelation("BookingToBookingMNI",dsBooking.Tables["Booking"].Columns["Record_Id"],dsBooking.Tables["Booking_MNI"].Columns["booking_record_id"]); dsBooking.Relations.Add(relBookingMNI); </code></pre> <p>dsBooking is my main dataset that contains 2 tables Booking and Booking_MNI Where the Record_Id is the primary key and booking_record_id is the foreign key</p> <p>I changed the code below to match my first example. But I think this is what you are looking for. In our production code this will produce the plus "+" symbol to the left of the row which would allow you to drill into the related table. Again I took production code and made it look like the first example so I don't know if it will compile but it should get you going in the right direction. </p> <pre><code>DataTable dtBooking = ds.Tables[0]; DataTable dtBooking_MNI = ds.Tables[1]; dtBooking.PrimaryKey = new DataColumn[] {dtBooking.Columns["Record_Id"]}; dtBooking_MNI.PrimaryKey = new DataColumn[] {dtBooking_MNI.Columns["booking_Record_Id"]}; /* Setup DataRelation between the DataTables */ DataColumn[] dcBookingColsArray = new DataColumn[1] {dtBooking.Columns["Record_Id"]}; DataColumn[] dcBookingMNIColsArray = new DataColumn[1] {dtBooking_MNI.Columns["booking_record_Id"]}; DataRelation relBooking_To_MNI = new DataRelation("Booking_To_MNI",dcBookingColsArray,dcBookingMNIColsArray); ds.Relations.Add(relBooking_To_MNI_Units); // grid where you want to display the relationship grdBooking.DataSource = ds; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload