OleDb connection.close()每次需要40s以上的时间来执行,一口气做完很多事情需要3分钟才能完成。不知道该怎么办,互联网上似乎没人能找到解决方案。在极少数情况下,它可以正常执行并且以我期望的速度执行,但是我不知道该如何重现。
实际的数据库本身很好,并且不需要很长时间就可以在Access中加载
Public Sub loadCoords(orderstoset As List(Of Order))
For Each order In orderstoset
Dim query As String = "SELECT Address FROM Clients WHERE ClientID = '" & order.getID & "';"
Dim myConnection As OleDbConnection = New OleDbConnection
Dim myDataReader As OleDbDataReader
myConnection.ConnectionString =
"provider=Microsoft.ace.oledb.12.0;Data Source = C:\Users\jackw\OneDrive\Access Database\WaggyTailzDatabase.accdb"
Try
myConnection.Open()
Dim myCommand As OleDbCommand = New OleDbCommand(query, myConnection)
myDataReader = myCommand.ExecuteReader
While myDataReader.Read
Dim coords As String
Dim myOrder As New Order
Dim address As String = myDataReader("Address").ToString
coords = addressToLatLon(address)
order.setCoords(coords)
i += 1
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try
myConnection.Close()
Next
End Sub
也尝试了.Dispose(),同样的事情。没有错误消息或其他任何内容,仅花费很长时间,考虑到我这样做的时间,这很烦人。这不是发生这种情况的唯一部分,多了一些,他们都做同样的事情。
感谢您的帮助