一共13列,10万条数据,代码如下,运行10秒钟报OutOfMemoryException错误,谁能提供更好的解决方案?
1 StringBuilder sb = new StringBuilder();
2 //0:出错消息,1:出错行
3 for (int i = 0; i < desTable.Rows.Count; i++)
4 {
5
6 DataRow row = messTable.NewRow();
7 foreach (string item in emptyValidStr)
8 {
9 if (string.IsNullOrEmpty(desTable.Rows[i][item].ToString()))
10 {
11 sb.AppendFormat("{0}不能为空|", item);
12 flag = false;
13 continue;
14 }
15 if (item == "CardCode")
16 {
17 if (!Regex.IsMatch(desTable.Rows[i][item].ToString(), CardCode))
18 {
19 sb.AppendFormat("{0}格式不正确|", item);
20 }
21 flag = false;
22 continue;
23 }
24 if (item == "VINCode")
25 {
26 if (!Regex.IsMatch(desTable.Rows[i][item].ToString(), VINCode))
27 {
28 sb.AppendFormat("{0}格式不正确|", item);
29 }
30 flag = false;
31 continue;
32 }
33 }
34
35 if (flag == false)
36 {
37 row[0] = sb.ToString();
38 row[1] = i + 1;
39 errTable.Rows.Add(souTable.Rows[i].ItemArray);
40 desTable.Rows.RemoveAt(i);
41 }
42 }
添加回答
举报
0/150
提交
取消