下面的合并代码,在合并数据时项目处于假死状态,或干脆死机(8G内存了),几千条的数据合并到13万条的数据表中,很长一段时间才能合并完,怎么改才能真正高速呢。
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim c As Integer = 0
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("物资字典").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"上级编号","物资编码","物资名称","规格型号","计量单位"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count -1
Dim bh As String = sheet(n,0).Text
If DataTables("物资字典").Find("物资编码 = '" & bh & "'") Is Nothing Then '如果不存在同编号的订单
Dim r As Row = Tables("物资字典").AddNew()
c=c+1
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(n,m).Value
Next
End If
Next
Tables("物资字典").ResumeRedraw()
DataTables("物资字典").Save
MessageBox.Show("导入完成,共导入" & c & "条记录")
End If