Free mag vol1 | Page 955

CHAPTER 22  ADO.NET PART II: THE DISCONNECTED LAYER // Loop through all orders for this customer. foreach (DataRow order in drsOrder) { strOrderInfo += string.Format("----\nOrder Number: {0}\n", order["OrderID"]); // Get the car referenced by this order. DataRow[] drsInv = order.GetParentRows(autoLotDS.Relations[ "InventoryOrder"]); // Get info for (SINGLE) car info for this order. DataRow car = drsInv[0]; strOrderInfo += string.Format("Make: {0}\n", car["Make"]); strOrderInfo += string.Format("Color: {0}\n", car["Color"]); strOrderInfo += string.Format("Pet Name: {0}\n", car["PetName"]); } MessageBox.Show(strOrderInfo, "Order Details"); } Figure 22-13 shows one possible output when specifying a customer ID with the value of 3 (your output may differ based on the data within your AutoLot database tables). Figure 22-13. Navigating data relations 901