• 把datatable的某些数据提取出来放在另一个表中


      /// <summary>
            /// 把table表里的某行数据提取出来放到别一个表中,并在原表中删除这行数据
            /// </summary>
            /// <param name="startDatatable">源表</param>
            /// <param name="indexKey">提取行号</param>
            /// <returns>返加datatable数组。第一个数组是源表,第二个数组是目标组</returns>
            public static DataTable[] CheckDatatable(DataTable startDatatable, int indexKey)
            {
                DataTable dbdbTongmadeplayfulelementHead = startDatatable.Clone();
                int intRowCount = startDatatable.Rows.Count;
                if ((intRowCount > 0) && (intRowCount > indexKey))
                {

                    DataRow dr = dbdbTongmadeplayfulelementHead.NewRow();
                    dr.ItemArray = startDatatable.Rows[indexKey].ItemArray;
                    dbdbTongmadeplayfulelementHead.Rows.Add(dr);
                    DataRow tempdatarow = startDatatable.Rows[indexKey];
                    startDatatable.Rows.Remove(tempdatarow);
                    startDatatable.AcceptChanges();
                    return new DataTable[] { startDatatable, dbdbTongmadeplayfulelementHead };
                }
                else
                {
                    return null;
                }
            }

            /// <summary>
            /// 把table表里的某行数据提取出来放到别一个表中,并在原表中删除这些数据
            /// </summary>
            /// <param name="startDatatable">源表</param>
            /// <param name="StartindexKey">起适行号</param>
            /// <param name="EndindexKey">结束行号</param>
            /// <returns>返加datatable数组。第一个数组是源表,第二个数组是目标组</returns>
            public static DataTable[] CheckDatatable(DataTable startDatatable, int StartindexKey, int EndindexKey)
            {
                DataTable dbdbTongmadeplayfulelementHead = startDatatable.Clone();
                int intRowCount = startDatatable.Rows.Count;
                if ((intRowCount > 0) && (intRowCount >= StartindexKey) && (intRowCount >= EndindexKey))
                {
                    for (int i = StartindexKey; i <= EndindexKey; i++)
                    {
                        DataRow dr = dbdbTongmadeplayfulelementHead.NewRow();
                        dr.ItemArray = startDatatable.Rows[i].ItemArray;
                        dbdbTongmadeplayfulelementHead.Rows.Add(dr);

                    }
                    int j = 0;
                    do
                    {
                        DataRow tempdatarow = startDatatable.Rows[StartindexKey - j];
                        startDatatable.Rows.Remove(tempdatarow);
                        j++;
                        StartindexKey++;
                    } while (StartindexKey <= EndindexKey);

                    startDatatable.AcceptChanges();
                    return new DataTable[] { startDatatable, dbdbTongmadeplayfulelementHead };
                }
                else
                {
                    return null;
                }
            }


       本人博客的文章大部分来自网络转载,因为时间的关系,没有写明转载出处和作者。所以在些郑重的说明:文章只限交流,版权归作者。谢谢

  • 相关阅读:
    从大量的IP访问记录中找到访问次数最多的IP
    打赏功能的实现
    MFC通过ODBC连接Mysql程序
    VC++中使用MFC通过ADO连接数据库
    MySQL 5.1参考手册
    MFC ADO mysql 经验总结一
    VC连接MySQL
    VC连接MySQL
    MFC使用ADO对象开发数据库应用程序
    MFC中用Ado连接数据库
  • 原文地址:https://www.cnblogs.com/wzg0319/p/1717450.html
Copyright © 2020-2023  润新知