Dim Builders As New System.Data.OleDb.OleDbConnectionStringBuilder
Builders("Provider") = "Microsoft.Jet.OLEDB.4.0"
Builders("Data Source") = "C:\Users\John\Documents\Visual Studio 2008\Projects\SimpleSQLTest\SimpleSQLTest\dictionary.mdb"
' Dim sSQL1 As String = "Select Words, synonym from [Word List];"
Dim sSQL1 As String = "SELECT lemma, def from [def look-up];"
Dim i As Integer = 0
Dim z As Integer
Using Connection As New OleDbConnection(Builders.ToString)
Dim command As New OleDbCommand(sSQL1, Connection)
Connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader
'reader.Read()
While reader.Read
i = i + 1
ReDim Preserve Word(i)
ReDim Preserve DeforSyn(i)
Word(i) = reader(0).ToString
DeforSyn(i) = reader(1).ToString
'Form1.TextBox1.Text = reader(0).ToString()
Form1.TextBox1.Text = reader(0).ToString & " " & reader(1).ToString
End While
End Using
MsgBox(i)
因此试图加快查询速度。读取最后一项只是为了看它需要多长时间。我在VB6中做了一个不同的方法,它加载速度非常快。试图加载超过200,000行的字典。谢谢你的建议。
答案 0 :(得分:4)
Redim可能是一项昂贵的操作。你试过开始:
select count(*) from [def look-up]
在开始检索数据之前创建正确大小的数组?