H
Henry
I got a dataset with three tables 'Parent', 'Child' and 'Grandchild'.
The relation will *work* on "Parent" and "child". KEYs from "Parent"
will cascade to "Child" without any problem. However "Child" and
"Grandchild" relation won't work. KEYs in the "Child" table only
cascade once to the "Grandchild" table. Subsequence records from
"Child" won't cascade to the "Grandchild" table. I bind those three
tables into three separate DataGrid. Attach are the dataset and
relation I am using right now. I really appreciate anyone can help
figure this out... Thanks
Henry
//*********************
//Parent Child DataGrid
//*********************
ParentDataGrid.DataSource = ds;
ParentDataGrid.DataMember="Parent";
ChildDataGrid.DataSource = ds;
ChildDataGrid.DataMember="ds.Parent_Child";
GrandChildDataGrid.DataSource = ds;
GrandChildDataGrid.DataMember="ds.Child_GrandChild";
//*********************
//DATASET
//*********************
tbl = ds.Tables.Add("Parent");
col = tbl.Columns.Add("ParentID", typeof(System.Int32));
col.AllowDBNull = false;
col.AutoIncrement = true;
col.AutoIncrementSeed = -1;
col.AutoIncrementStep = -1;
col.ReadOnly = true;
col.Unique = true; tbl.PrimaryKey = new DataColumn[]
{tbl.Columns["ParentID"]};
tbl = ds.Tables.Add("Child");
col = tbl.Columns.Add("ChildID", typeof(System.Int32));
col.AllowDBNull = false;
col.AutoIncrement = true;
col.AutoIncrementSeed = -1;
col.AutoIncrementStep = -1;
col.ReadOnly = true; col.Unique = true;
col = tbl.Columns.Add("ParentID", typeof(System.Int32));
col.AllowDBNull = false;
tbl.PrimaryKey = new DataColumn[] {tbl.Columns["ChildID"]};
tbl = ds.Tables.Add("GrandChild");
col = tbl.Columns.Add("GrandChildID", typeof(System.Int32));
col.AllowDBNull = false;
col.AutoIncrement = true;
col.AutoIncrementSeed = -1;
col.AutoIncrementStep = -1;
col.ReadOnly = true;
col.Unique = true;
col = tbl.Columns.Add("ChildID", typeof(System.Int32));
col.AllowDBNull = false;
tbl.PrimaryKey = new DataColumn[] {tbl.Columns["GrandChildID"]};
//*********************
//Data Relation
//*********************
ds.Relations.Add("Parent_Child",ds.Tables["Parent"].Columns["ParentID"],ds.Tables["Child"].Columns["ParentID"]);
ds.Relations.Add("Child_GrandChild",ds.Tables["Child"].Columns["ChildID"],ds.Tables["GrandChild"].Columns["ChildID"]);
The relation will *work* on "Parent" and "child". KEYs from "Parent"
will cascade to "Child" without any problem. However "Child" and
"Grandchild" relation won't work. KEYs in the "Child" table only
cascade once to the "Grandchild" table. Subsequence records from
"Child" won't cascade to the "Grandchild" table. I bind those three
tables into three separate DataGrid. Attach are the dataset and
relation I am using right now. I really appreciate anyone can help
figure this out... Thanks

Henry
//*********************
//Parent Child DataGrid
//*********************
ParentDataGrid.DataSource = ds;
ParentDataGrid.DataMember="Parent";
ChildDataGrid.DataSource = ds;
ChildDataGrid.DataMember="ds.Parent_Child";
GrandChildDataGrid.DataSource = ds;
GrandChildDataGrid.DataMember="ds.Child_GrandChild";
//*********************
//DATASET
//*********************
tbl = ds.Tables.Add("Parent");
col = tbl.Columns.Add("ParentID", typeof(System.Int32));
col.AllowDBNull = false;
col.AutoIncrement = true;
col.AutoIncrementSeed = -1;
col.AutoIncrementStep = -1;
col.ReadOnly = true;
col.Unique = true; tbl.PrimaryKey = new DataColumn[]
{tbl.Columns["ParentID"]};
tbl = ds.Tables.Add("Child");
col = tbl.Columns.Add("ChildID", typeof(System.Int32));
col.AllowDBNull = false;
col.AutoIncrement = true;
col.AutoIncrementSeed = -1;
col.AutoIncrementStep = -1;
col.ReadOnly = true; col.Unique = true;
col = tbl.Columns.Add("ParentID", typeof(System.Int32));
col.AllowDBNull = false;
tbl.PrimaryKey = new DataColumn[] {tbl.Columns["ChildID"]};
tbl = ds.Tables.Add("GrandChild");
col = tbl.Columns.Add("GrandChildID", typeof(System.Int32));
col.AllowDBNull = false;
col.AutoIncrement = true;
col.AutoIncrementSeed = -1;
col.AutoIncrementStep = -1;
col.ReadOnly = true;
col.Unique = true;
col = tbl.Columns.Add("ChildID", typeof(System.Int32));
col.AllowDBNull = false;
tbl.PrimaryKey = new DataColumn[] {tbl.Columns["GrandChildID"]};
//*********************
//Data Relation
//*********************
ds.Relations.Add("Parent_Child",ds.Tables["Parent"].Columns["ParentID"],ds.Tables["Child"].Columns["ParentID"]);
ds.Relations.Add("Child_GrandChild",ds.Tables["Child"].Columns["ChildID"],ds.Tables["GrandChild"].Columns["ChildID"]);