ZZ

--

/// <summary>
/// 分批处理。
/// </summary>
public void PartialProc()
{
int per_count = ;//每个datatable行数。每4行处理一次。
DataTable dt = new DataTable();
dt.Columns.Add("barcode");
dt.Columns.Add("qty");
dt.Rows.Add("a", "");
dt.Rows.Add("b", "");
dt.Rows.Add("c", "");
dt.Rows.Add("d", "");
dt.Rows.Add("e", "");
dt.Rows.Add("f", "");
dt.Rows.Add("g", "");
dt.Rows.Add("h", "");
dt.Rows.Add("i", "");
dt.Rows.Add("j", "");
dt.Rows.Add("k", ""); DataTable dtPer = dt.Clone();
int count = dt.Rows.Count;
int pages = count % per_count == ? count / per_count : count / per_count + ;//最终DataTable个数
List<DataTable> list = new List<DataTable>();
for (int i = ; i < pages; i++)
{
#region 这个是LINQ方式
//list.Add(dt.AsEnumerable().Skip(i * pre_count).Take(pre_count).CopyToDataTable());
#endregion #region 这个是LINQ方式
if (i == pages - )
{
dtPer = dt.Clone();
for (int j = i * per_count; j < count; j++)
{
dtPer.Rows.Add(dt.Rows[j][], dt.Rows[j][]);
} DoIt(dtPer);
}
else
{
dtPer = dt.Clone();
for (int j = i * per_count; j < (i + ) * per_count; j++)
{
dtPer.Rows.Add(dt.Rows[j][], dt.Rows[j][]);
} DoIt(dtPer);
}
#endregion
}
//list为最终拆分的DataTable集合
string som2 = string.Empty;
} public void DoIt(DataTable dtProc)
{ }

ZZ

--

ZZ

DataTable 分批处理,每批处理4行的更多相关文章

  1. 批处理命令行CMD启动停止重启IIS的命令

    原文:批处理命令行CMD启动停止重启IIS的命令 启动IIS: net start iisadmin    (IIS的整个服务) net start w3svc       (WWW网页WEB服务) ...

  2. DataTable经典报错{列/行已属于其他表}

    Delete()之后需要datatable.AccepteChanges()方法确认完全删除,因为Delete()只是将相应列的状态标志为删除, 还可以通过datatable.RejectChange ...

  3. 循环删除DataTable.Row中的多行问题

    在C#中,如果要删除DataTable中的某一行,大约有以下几种办法: 1,使用DataTable.Rows.Remove(DataRow),或者DataTable.Rows.RemoveAt(ind ...

  4. Windows下的一个Nginx 批处理命令行控制台

    其实作用很简单,就是为了少输入几个字母,完成对Nginx的控制而已,同时也算是练习了一把bat批处理吧. @echo off&color e&Title Nginx 命令行控制台 cl ...

  5. DataTable如何去除重复的行

    两种方法1 数据库直接去除重复select distinct * from 表名去除了重复行distinct 2 对 DataTable直接进行操作DataTable dt=db.GetDt(&quo ...

  6. 【转】C# DataTable 导出 Excel 进阶 多行表头、合并单元格、中文文件名乱码

    本文原创地址:http://blog.csdn.net/ranbolwb/article/details/8083983 ,转载请保留本行. 本例子是上一篇 DataTable 导出 Excel 的进 ...

  7. 将n行3列的数据dataTable装换成m行7列的dataTable

    //思路:新建dataTable,定义需要的列, 先将数据源进行分组,第一重遍历获取所有组,第二重遍历获取某一个组的具体数据public void DataBind() { DateTime time ...

  8. 去除DataTable指定列的重复行

    DataTable dt = ds.Tables[]; //获得 datatable DataView dv = new DataView(dt); DataTable dt2 = dv.ToTabl ...

  9. 去掉DataTable列中的重复行

    DataTable  dt = ds.Tables[0];    //获得 DataTable  DataView dv = new DataView(dt);DataTable dt2 = dv.T ...

随机推荐

  1. 我的一起开源网 www.17ky.net上线了

    .net开源生态的落后,使得.net开发人员所拥有的开源资源比其他语言的开发者少了很多,这也使得笔者很早之前就喜欢收集各种开源项目,经常会去逛codeplex,开源中国社区等网站,同时也喜欢在自己或公 ...

  2. bzoj1677

    题解: 背包 每一个1<<i都是无限量 代码: #include<bits/stdc++.h> using namespace std; ,M=1e9; int n,dp[N] ...

  3. oracle不小心更新了数据库中的所有内容后的恢复

    开发过程中,在更新数据库中的某一条数据时,由于疏忽忘记加where判断条件了,这时更新会提示是否要更新全部数据,但是由于自己没有仔细看提示导致直接点确定并commit了,导致数据库中所有数据的相关字段 ...

  4. android源码追踪学习 RecipientsEditor

    RecipientsEditor 新建短信时输入收接者的editor, public class RecipientsEditor extends MultiAutoCompleteTextView  ...

  5. ContentType&CORS&Git

    ContentType django内置的ContentType组件就是帮我们做连表操作 如果一个表与其他表有多个外键关系,我们可以通过ContentType来解决这种关联 from django.d ...

  6. 【Android SDK Manager】SDk国内镜像下载地址

    中国科学院开源协会镜像站地址: IPV4/IPV6: http://mirrors.opencas.cn 端口:80 IPV4/IPV6: http://mirrors.opencas.org 端口: ...

  7. Texas Instruments matrix-gui-2.0 hacking -- generate.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  8. Failed to fetch URl https://dl-ssl.google.com/android/repository/addo Android SDK更新以及ADT更新出现问题的解决办法

    问题描述 使用SDK Manager更新时出现问题Failed to fetch URL https://dl-ssl.google.com/android/repository/repository ...

  9. CentOS 7关闭图形桌面开启文本界面

    1,命令模式systemctl set-default multi-user.target 2,图形模式systemctl set-default graphical.target CentOS 7 ...

  10. 任务三 简单程序测试及 GitHub Issues 的使用

    我提交的Issue 我被提出的Issue 在使用Issue的过程中我发现提出的Issue不能指派任务人和问题类型,被提出的Issue可以. 碰到最多的问题是测试程序的过程中, 比如用户未按指定格式输入 ...