老师,以下这个BOM有几百万行,用以下代码太慢了,如何用Dim sql As String 来实现 ? 是不是会更快些 ?谢谢。
Dim cmd As New SQLCommand
Dim dt As DataTable
DataTables("BOM").datarows.clear
DataTables("BOM").save
cmd.C
Dim Cols1() As String = {"BomId","SortSeq","ComponentId","BaseQtyN","BaseQtyD","ParentId","Version","cInvName","VersionDesc","cInvCode"}
Dim Cols2() As String = {"BomId","SortSeq","ComponentId","BaseQtyN","BaseQtyD","ParentId","Version","cInvName","VersionDesc","cInvCode"}
cmd.CommandText ="Sel ect {bom_opcomponent}.BomId,SortSeq,ComponentId,BaseQtyN,BaseQtyD,ParentId,Version,cInvName,VersionDesc,cInvCode From (((({bom_opcomponent} Left JOIN {bom_parent} ON {bom_parent}.[BomId] = {bom_opcomponent}.[BomId]) Left JOIN {bom_bom} ON {bom_bom}.[BomId] = {bom_opcomponent}.[BomId]) Inner JOIN {bas_part} ON {bas_part}.[PartId] = {bom_opcomponent}.[ComponentId]) Inner JOIN {Inventory} ON {Inventory}.[cInvCode] = {bas_part}.[InvCode]) Where Status <> 4"
dt = cmd.ExecuteReader()
For Each dr1 As DataRow In dt.DataRows
Dim dr2 As DataRow = DataTables("BOm").AddNew()
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
Tables("BOM").ResumeRedraw()