2010-11-23 70 views
0
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行的字典。感謝您的建議。建議加快vb.net訪問查詢來填充數組

+0

絕對有很多Access數據庫的記錄。我已經閱讀過有關Access的SP,但從未嘗試過。 - http://hubpages.com/hub/Stored_Procedure_in_MS_Access – N0Alias 2010-11-23 03:26:06

+0

可能有興趣:http://thedailyreviewer.com/dotnet/view/getrows-equivalent-106118737 – Fionnuala 2010-11-23 10:18:52

回答

4

Redim可能是一個昂貴的操作。您是否嘗試過:

select count(*) from [def look-up] 

然後在開始檢索數據之前創建正確大小的數組?