when u use the follow code on 1.1.it will compile without error. 

        /// <summary>
        
/// Test table relation.
        
/// </summary>

        public void Relation_1_1()
        
{
            DataTable dtParent 
= this.CreateDataTable();
            dtParent.TableName 
= "Parent";

            DataRelation relations 
= ds.Relations.Add("Relation", dtParent.Columns["index"], dtParent.Columns["parent_index"], false);

            
this.builder.Append(" Get the data from tree ROOT.");
            
this.GetLayerFromParent(ds, relations);
            
this.PrintDataTable(ds.Tables["parent"]);

            
this.builder.Append(" Get the data from tree CHILDS.");
            
this.GetLayerFromChilds(ds, relations);
            
this.PrintDataTable(ds.Tables["parent"]);

            
this.DebugPrint(this.builder.ToString());
        }

 

while it will run error on 2.0 with "Cannot create a DataRelation if Parent or Child Columns are not in a DataSet.".

if u want to run normally,u can use this cod:

 

/// <summary>
        
/// Test table relation.
        
/// </summary>

        public void Relation_2_0()
        
{
            DataTable dtParent 
= this.CreateDataTable();
            dtParent.TableName 
= "Parent";

            DataSet ds 
= new DataSet();
            ds.Tables.Add(dtParent);
            DataRelation relations 
= ds.Relations.Add("Relation", ds.Tables["Parent"].Columns["index"], ds.Tables["Parent"].Columns["parent_index"], false);

            
this.builder.Append(" Get the data from tree ROOT.");
            
this.GetLayerFromParent(ds, relations);
            
this.PrintDataTable(ds.Tables["parent"]);

            
this.builder.Append(" Get the data from tree CHILDS.");
            
this.GetLayerFromChilds(ds, relations);
            
this.PrintDataTable(ds.Tables["parent"]);

            
this.DebugPrint(this.builder.ToString());
            
            
//this.WriteToTxtFile(this.builder.ToString());
        }

what's your idea?

posted on 2007-09-04 23:05  孤剑  阅读(292)  评论(0编辑  收藏  举报