阅读背景:

c#每循环100次提交一次数据,最后一次不足100次提交一次

来源:互联网 
            StringBuilder sb=new StringBuilder();
            string strId=dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["id"].Value.ToString();
            int iCnt = 0;//临时计数器
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                sb.AppendFormat("update t_location set exportflag='1' where id={0}",strId);
                iCnt += 1;
                if (iCnt == 100)
                {
                    DBUtility.DB.FromSql(sb.ToString()).Execute();
                    sb.Clear();
                    iCnt = 0;
                }
            }
            if (sb.ToString() != "")
            {
                DBUtility.DB.FromSql(sb.ToString()).Execute();
            }
            StringBuilder sb=new StringBuil



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: