• the differences of DataRelation class between 1.1 and 2.0


    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?

  • 相关阅读:
    opencv中彩色图转换成灰度图rgb2gray
    C和MATLAB中:同时对多个变量连续赋值
    error LNK2019: 无法解析的外部符号
    空间中两直线位置关系
    百度网盘不能绑定QQ
    matlab中双站异面直线法定位目标
    Sublime Text3编辑器简介
    Sybase IQ使用过程中注意事项
    Sybase数据库常用函数
    Sybase数据库第三方软件安装
  • 原文地址:https://www.cnblogs.com/AloneSword/p/2237541.html
Copyright © 2020-2023  润新知