【发布时间】:2011-08-09 12:45:10
【问题描述】:
请帮我让我的应用程序更快一点,它需要很长时间才能循环并立即给我结果。
这是我做的: 1.从上传的excel文件中加载gridview(这可能是大约300条左右的记录) 2. 将制造商、型号和序列号与我的 MS SQL 数据库(大约 20K 条记录)进行比较,看看是否匹配。
'find source ID based on make/model/serial No combination.
Dim cSource As New clsSource()
Dim ds As DataSet = cSource.GetSources()
Dim found As Boolean = False
'populate db datatables
Dim dt As DataTable = ds.Tables(0)
Dim rows As Integer = gwResults.Rows.Count()
For Each row As GridViewRow In gwResults.Rows
'move through rows and check data in each row against the dataset
'1 - make
For Each dataRow As DataRow In dt.Rows
found = False
If dataRow("manufacturerName") = row.Cells(1).Text Then
If dataRow("modelName") = row.Cells(2).Text Then
If dataRow("serialNo") = row.Cells(3).Text Then
found = True
End If
End If
End If
'display results
If found Then
lblResults.Text += row.Cells(1).Text & "/" & row.Cells(2).Text & "/" & row.Cells(3).Text & " found"
Else
lblResults.Text += row.Cells(1).Text & "/" & row.Cells(2).Text & "/" & row.Cells(3).Text & " not found "
End If
Next
Next
有没有更好的方法来找到两者之间的匹配?我要死在这里了。
【问题讨论】:
标签: sql-server vb.net gridview loops