Developer fusion[
^] auto translated it (once I had corrected the comment immediately after the Nodes.Clear)
DataSet DSNWind = null;
System.Data.SqlClient.SqlConnection CNnwind = new System.Data.SqlClient.SqlConnection("DATA SOURCE=Server;USER ID=sa;INITIAL CATALOG=northwind;");
System.Data.SqlClient.SqlDataAdapter DACustomers = new System.Data.SqlClient.SqlDataAdapter("SELECT CustomerID, CompanyName, ContactName, Country FROM customers WHERE country = 'Germany'", CNnwind);
System.Data.SqlClient.SqlDataAdapter DAOrders = new System.Data.SqlClient.SqlDataAdapter("SELECT CustomerID, OrderID, OrderDate, ShippedDate, ShipVia, Freight FROM orders where customerid in (select customerid from customers where country = 'Germany')", CNnwind);
System.Data.SqlClient.SqlDataAdapter DAOrderDetails = new System.Data.SqlClient.SqlDataAdapter("Select * from [Order Details] where OrderID in (SELECT OrderID FROM orders where customerid in (select customerid from customers where country = 'Germany'))", CNnwind);
DSNWind = new DataSet();
CNnwind.Open();
DACustomers.Fill(DSNWind, "dtCustomers");
DAOrders.Fill(DSNWind, "dtOrders");
DAOrderDetails.Fill(DSNWind, "dtOrderDetails");
CNnwind.Close();
DSNWind.Relations.Add("CustToOrd", DSNWind.Tables["dtCustomers"].Columns["CustomerID"], DSNWind.Tables["dtOrders"].Columns["CustomerID"]);
DSNWind.Relations.Add("OrdToDet", DSNWind.Tables["dtOrders"].Columns["OrderID"], DSNWind.Tables["dtOrderdetails"].Columns["OrderID"]);
TreeView1.Nodes.Clear();
DataRow parentrow = null;
DataTable ParentTable = null;
ParentTable = DSNWind.Tables["dtCustomers"];
foreach (DataRow parentrow_loopVariable in ParentTable.Rows) {
parentrow = parentrow_loopVariable;
TreeNode parentnode = default(TreeNode);
parentnode = new TreeNode(parentrow[0]);
TreeView1.Nodes.Add(parentnode);
DataRow childrow = null;
TreeNode childnode = default(TreeNode);
childnode = new TreeNode();
foreach (DataRow childrow_loopVariable in parentrow.GetChildRows("CustToOrd")) {
childrow = childrow_loopVariable;
childnode = parentnode.Nodes.Add(childrow[0] + " " + childrow[1] + " " + childrow[2]);
childnode.Tag = childrow["OrderID"];
DataRow childrow2 = null;
TreeNode childnode2 = default(TreeNode);
childnode2 = new TreeNode();
foreach (DataRow childrow2_loopVariable in childrow.GetChildRows("OrdToDet")) {
childrow2 = childrow2_loopVariable;
childnode2 = childnode.Nodes.Add(childrow2[0]);
}
}
}