现状如下:,程序中有3个类似的分段查询语句,分别查询当前指令单号的:入库明细,领料明细、委外采购记录
''------------------以下是收集产品入库单号
cmd1.CommandText = "SELECT mr0.DOC_NO mr0DOC_NO,w1.WAREHOUSE_NAME" ’在入库档案中的记录,取:入库单号和入库名称
cmd1.CommandText = cmd1.CommandText & " FR OM {MO} As m1 full join {MO_RECEIPT_D} As mr1 on m1.MO_ID=mr1.MO_ID inner join MO_RECEIPT As mr0 on mr1.MO_RECEIPT_ID=mr0.MO_RECEIPT_ID left join {WAREHOUSE} as w1 on mr1.WAREHOUSE_ID=w1.WAREHOUSE_ID"
cmd1.CommandText = cmd1.CommandText & " WHERE m1.[DOC_NO] ='"& str01 &"' and mr0.[ApproveStatus]='Y' ORDER BY m1.DOC_NO" '取所有入库记录号
db01 = cmd1.ExecuteReader() '求所有入库单号可以修改和保存
str04=Nothing
If db01.DataRows.Count > 0 Then '如果入库单号有记录
For Each dr01 As DataRow In db01.DataRows '收集入库单号
str04=str04 & dr01("mr0DOC_NO").trim() & "(" & dr01("WAREHOUSE_NAME").trim() & ")/" ’生成一个字符串
Next
dr1("rkdh01")=str04 ‘将字符串写入字段
End If
以上红颜色的语句,在生成字符串时消耗了大量时间,请教如何优化呢?
谢谢专家!
[此贴子已经被作者于2019/6/13 12:59:33编辑过]