以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]为什么这段代码执行起来这么吃力? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=107754) |
-- 作者:newitman -- 发布时间:2017/10/9 13:35:00 -- [求助]为什么这段代码执行起来这么吃力? 代码: Select Case e.DataCol.Name Case "AutoID" Dim dr As DataRow = DataTables("PODetails").SQLFind("AutoID= " & e.NewValue) e.DataRow("StyleID") = dr("StyleID") e.DataRow("PO") = dr("PO") e.DataRow("Model") = dr("Model") e.DataRow("Color") = dr("Color") e.DataRow("Material") = dr("Material") e.DataRow("Country") = dr("Country") \'提取库存 e.DataRow("RKSize1") = DataTables("TabRKBill").SQLCompute("Sum(Size1)","AutoID = " & e.NewValue) e.DataRow("CKSize1") = DataTables("TabCKBill").SQLCompute("Sum(Size1)","AutoID = " & e.NewValue) e.DataRow("RKSize2") = DataTables("TabRKBill").SQLCompute("Sum(Size2)","AutoID = " & e.NewValue) e.DataRow("CKSize2") = DataTables("TabCKBill").SQLCompute("Sum(Size2)","AutoID = " & e.NewValue) e.DataRow("RKSize3") = DataTables("TabRKBill").SQLCompute("Sum(Size3)","AutoID = " & e.NewValue) e.DataRow("CKSize3") = DataTables("TabCKBill").SQLCompute("Sum(Size3)","AutoID = " & e.NewValue) e.DataRow("RKSize4") = DataTables("TabRKBill").SQLCompute("Sum(Size4)","AutoID = " & e.NewValue) e.DataRow("CKSize4") = DataTables("TabCKBill").SQLCompute("Sum(Size4)","AutoID = " & e.NewValue) e.DataRow("RKSize5") = DataTables("TabRKBill").SQLCompute("Sum(Size5)","AutoID = " & e.NewValue) e.DataRow("CKSize5") = DataTables("TabCKBill").SQLCompute("Sum(Size5)","AutoID = " & e.NewValue) e.DataRow("RKSize6") = DataTables("TabRKBill").SQLCompute("Sum(Size6)","AutoID = " & e.NewValue) e.DataRow("CKSize6") = DataTables("TabCKBill").SQLCompute("Sum(Size6)","AutoID = " & e.NewValue) e.DataRow("RKSize7") = DataTables("TabRKBill").SQLCompute("Sum(Size7)","AutoID = " & e.NewValue) e.DataRow("CKSize7") = DataTables("TabCKBill").SQLCompute("Sum(Size7)","AutoID = " & e.NewValue) e.DataRow("RKSize8") = DataTables("TabRKBill").SQLCompute("Sum(Size8)","AutoID = " & e.NewValue) e.DataRow("CKSize8") = DataTables("TabCKBill").SQLCompute("Sum(Size8)","AutoID = " & e.NewValue) e.DataRow("RKSize9") = DataTables("TabRKBill").SQLCompute("Sum(Size9)","AutoID = " & e.NewValue) e.DataRow("CKSize9") = DataTables("TabCKBill").SQLCompute("Sum(Size9)","AutoID = " & e.NewValue) End Select 选择AutoID之后,然后这一行等全部统计出来得2-3秒。。。 能不能做一些优化? |
-- 作者:有点甜 -- 发布时间:2017/10/9 14:13:00 -- 使用sqlFind、sqlCompute的效率本身就不高,你还使用那么多次。
尽量把 TabRKBill 的数据都加载出来,然后用 find、compute,这样效率会高一些。
即便根据条件先加载 TabRKBill 表的数据,然后find、compute,都比你连续使用sqlcompute要快 |
-- 作者:newitman -- 发布时间:2017/10/9 14:34:00 -- 回复:(有点甜)使用sqlFind、sqlCompute的效率本身就... 哦,原来是这样子 好的,我改用别的方法试试。
|