private void MakeParentTable1()
{
// Create a new Table
_parentTable1 = new DataTable("ParentTable");
_dataSet = new DataSet("XmlDataSet");
DataColumn column;
DataRow row;
// Create new DataColumn, set DataType,
// ColumnName and add to Table.
column = new DataColumn();
column.DataType = typeof(int);
column.ColumnName = "id";
column.Unique = true;
// Add the Column to the DataColumnCollection.
_parentTable1.Columns.Add(column);
// Create second column
column = new DataColumn();
column.DataType = typeof(string);
column.ColumnName = "ParentItem";
column.AutoIncrement = false;
column.Caption = "ParentItem";
column.Unique = false;
// Add the column to the table
_parentTable1.Columns.Add(column);
// Create third column.
column = new DataColumn();
column.DataType = typeof(int);
column.ColumnName = "DepartmentID";
column.Caption = "DepartmentID";
// Add the column to the table.
_parentTable1.Columns.Add(column);
// Make the ID column the primary key column.
DataColumn[] PrimaryKeyColumns = new DataColumn[2];
PrimaryKeyColumns[0] = _parentTable1.Columns["id"];
PrimaryKeyColumns[1] = _parentTable1.Columns["DepartmentID"];
_parentTable1.PrimaryKey = PrimaryKeyColumns;
_dataSet.Tables.Add(_parentTable1);
// Create three new DataRow objects and add
// them to the DataTable
for (int i = 0; i <= 2; i++)
{
row = _parentTable1.NewRow();
row["id"] = i + 1;
row["ParentItem"] = "ParentItem " + (i + 1);
row["DepartmentID"] = i + 1;
_parentTable1.Rows.Add(row);
}
}