这段代码执行了 6分多钟,不知道要怎么样优化好一点
Dim st As Date = Date.Now '将开始时间保存在变量st中
Dim t1 As Table = Tables(eform.na me & "_Tabl e1") ,成品表
Dim t3 As Table = Tables(eform.na me & "_Tab le3") '配件表
Dim sum As Integer
Dim cmd As New SQLCo mmand
cmd.Co nnec ti
For Each r1 As Row In t1.GetCheckedRows
For Each r3 As Row In t3.GetCheckedRows
cmd.Com mandText ="Sel ect Coun t(*) From {成品轨道BOM} Where 成品轨道编号 = '" & R1("成品轨道编号") & "' and 子配件编号 = '" & r3("物料编号") & "'"
If cmd.Execu teScalar > 0
Else
Dim txt As String = "Insert Into 成品轨道BOM (成品轨道编号,子配件编号)" & _
"Values('" & r1("成品轨道编号") & "', '" & r3("物料编号") & "')"
cmd.CommandText = txt
'cmd.CommandText = "Insert Into 成品轨道BOM (成品轨道编号,子配件编号) Values('" & r1("成品轨道编号") & "', '" & r3("物料编号") & "')"
cmd.ExecuteNonQuery
sum = sum +1
End If
Next
Next
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")
MessageBox.Show("成功导入" & sum & "条数据")