Databases Reference
In-Depth Information
{
drMap[iColumn] = dataRelation;
break;
}
}
iColumn ++;
}
//Iterate the rows of the first datatable and print their values.
foreach(DataRow row in dt.Rows)
{
iColumn = 0;
foreach(DataColumn column in dt.Columns)
{
if (drMap[iColumn] != null)
{
Console.WriteLine(column.ColumnName);
//Navigate to the nested table through relationship.
foreach(DataRow childRow in row.GetChildRows(drMap[iColumn]))
{
foreach(DataColumn childColumn in childRow.Table.Columns)
{
//If the column is a data column rather than a
//relationship column, print the data value.
if (! IsChildRelationColumn(drMap[iColumn],
childColumn))
{
object field = childRow[childColumn];
Console.WriteLine(“ “ +
childColumn.Caption + “=” + field.ToString());
}
}
}
}
else
{
object field = row [column];
Console.WriteLine(column.Caption + “=” + field.ToString());
}
iColumn++;
}
}
//Close the connection
con.Close();
}
//The helper function that detects whether the column is a child of the relation.
Search WWH ::




Custom Search