临时表删除行出错,在改进之前,先用sql语句删除吧,另外你这个代码临时表只用两列,没有必要加载所有列的:
Dim dt As DataTable
Dim cmd As new SQLCommand
Dim cmd1 As new SqlCommand
cmd.Connection Name = "xxx"
cmd1.Connection Name = "xxx"
cmd.CommandText = "select [_Identify],Material from {Request_Purchase}"
dt = cmd.ExecuteReader(True)
For Each r As Row In Tables("Purchase Orders_Order_Add").Rows
For Each dr As DataRow In dt.DataRows
If r("Material") = dr("Material") Then
cmd1.commandtext = "delete from {Request_Purchase} where [_Identify] = " & dr("_Identify")
cmd1.ExecuteNonQuery
End If
Next
Next