For Each id As Integer = 0 To msm.Length - 1
If (msm(id) <> tr) Then
Dim cmd1 As new SQLCommand
cmd1.C
cmd1.CommandText = "Exec kwsltjdec '" & mr("生产订单号码") & "','" & mr("工单行号") & "','" & mr("物料编码") & "','" & mr("库位编码") & "','" & mr("库位类别") & "'"
Dim t As DataTable = cmd1.ExecuteReader
mr.save
End If
Next
改为:
For Each id As Integer = 0 To msm.Length - 1
Dim match As Boolean = false
If (msm(id) = tr) Then
match = true
End If
if match = false then
Dim cmd1 As new SQLCommand
cmd1.C
cmd1.CommandText = "Exec kwsltjdec '" & mr("生产订单号码") & "','" & mr("工单行号") & "','" & mr("物料编码") & "','" & mr("库位编码") & "','" & mr("库位类别") & "'"
Dim t As DataTable = cmd1.ExecuteReader
mr.save
End if
Next