zoukankan      html  css  js  c++  java
  • 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?

  • 相关阅读:
    转载--php函数使用--var_export
    ZkApi的方法跨域访问ZkResource的静态资源文件出现的问题
    修改html内联样式的方法
    linux下的npm安装
    爬虫之静态网页爬虫(基础知识)
    利用jQuery使用HTML的formdata属性实现文件上传
    细说form表单
    session
    cookie和session(会话跟踪)
    同源策略和跨域问题
  • 原文地址:https://www.cnblogs.com/AloneSword/p/2237541.html
Copyright © 2011-2022 走看看