zoukankan      html  css  js  c++  java
  • 该行已经属于另一个表 的解决

    ----运用add方法的解决方案-------------------------------------------

    DataTable dt = new DataTable();
    dt = ds.Tables["All"].Clone();//把All的结构传递给dt
    DataRow[] dr=this.dataSet31.Tables["Product"].Select("bc=1");
    for(int i=0;i<dr.Length;i++)
    {
    //将数组元素加入表
    dt.Rows.Add(dr[i]);//出错提示为:该行已经属于另一个表
    }
    //解决方法
    dt.Rows.Add(dr[i].ItemArray);
    //这样就好了!


    -------运用insertAt方法的解决方案-------------------------------------


    假设有table1和table2
    你想把table1的内容插入到table2
    那么

    DataRow row = table2.NewRow();
    row.ItemArray = table1.Rows[你需要的Row的索引].ItemArray;
    table2.Rows.InsertAt(row,你插入的索引);

    一起学习GIS及其二次开发,一起进步!
  • 相关阅读:
    Spring中的一些常用接口
    ApplicationContextAware的作用
    用spring的 InitializingBean 的 afterPropertiesSet 来初始化
    虚拟机扩容(/dev/mapper/centos-root 空间不足)
    AJAX
    Git
    jQuery
    JS
    JS
    jQuery
  • 原文地址:https://www.cnblogs.com/tuncaysanli/p/1525464.html
Copyright © 2011-2022 走看看