之前是加载所有表,用Compute进行统计,很快只要200ms左右,现在全部改为SQLCompute,结果等了半小时都没反映。
Dim Sum1 As Single
Dim Sum2 As Single
Dim wlbm As String
For Each r1 As Row In Tables("物料信息表").Rows
wlbm = r1("物料编码")
Sum1 = DataTables("出入库表").SQLCompute("Sum(数量)", "入库仓 = '外协仓' And [物料编码] = '" & wlbm & "'")
Sum2 = DataTables("出入库表").SQLCompute("Sum(数量)", "出库仓 = '外协仓' And [物料编码] = '" & wlbm & "'")
r1("外协仓") = Sum1-Sum2
Sum1 = DataTables("出入库表").SQLCompute("Sum(数量)", "入库仓 = '成品仓' And [物料编码] = '" & wlbm & "'")
Sum2 = DataTables("出入库表").SQLCompute("Sum(数量)", "出库仓 = '成品仓' And [物料编码] = '" & wlbm & "'")
r1("成品仓") = Sum1-Sum2
Sum1 = DataTables("出入库表").SQLCompute("Sum(数量)", "入库仓 = '电子仓' And [物料编码] = '" & wlbm & "'")
Sum2 = DataTables("出入库表").SQLCompute("Sum(数量)", "出库仓 = '电子仓' And [物料编码] = '" & wlbm & "'")
r1("电子仓") = Sum1-Sum2
Next
高手支个招啊?
注:物料信息表有2000行数据,这个数据每次会全部加载,出入库表数据每月有10000行以上。
[此贴子已经被作者于2014-11-14 20:17:47编辑过]