For Each dr1 As DataRow In DataTables("表C").DataRows For Each dr2 As DataRows In DataTables("BOM明细表").Select("订货号 = '" & dr1("订货号") & "'") Select Case dr2("物料名称") Case "气缸体预装配" dr1("气缸体") = dr2("物料编码") Case "气缸盖分总成" dr1("气缸盖") = dr2("物料编码") Case "飞轮" dr1("飞轮") = dr2("物料编码") End Select Next Next