Results 1 to 1 of 1

Thread: Too Slow

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    83

    Too Slow

    Hi,

    I am reading only one field from the dbf file the problem I am having is that as the records exceed 2180 the program freezes but if it is 2180 then it is okay could someone please let me know what is the problem.

    My Code is:
    VB Code:
    1. Dim myReader As OleDbDataReader
    2.         Dim myOleDbConnection As OleDbConnection
    3.         Dim myOleDbCommand As OleDbCommand
    4.         Dim connectionString As String
    5.         Dim sqlQuery As String
    6.  
    7.         ' Initialize variables
    8.         ' Connection Less  (connection string):
    9.  
    10.         connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    11.                   "Data Source=c:\temp;" & _
    12.                   "Extended Properties=DBASE III;"
    13.  
    14.  
    15.         'connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Dsn=MyContactList"
    16.         ' SQL Statement to execute on the database
    17.         sqlQuery = "SELECT Examiner FROM Workload.dbf "
    18.         ' Instantiate the connection and the command
    19.         myOleDbConnection = New OleDbConnection(connectionString)
    20.         myOleDbCommand = New OleDbCommand(sqlQuery, myOleDbConnection)
    21.  
    22.         Try   ' error handling code (try and do the following)
    23.             ' Open the connection with the database
    24.             myOleDbConnection.Open()
    25.             ' Execute the SQL command and populate the data reader
    26.             myReader = myOleDbCommand.ExecuteReader()
    27.  
    28.             ' Loop through the contents of the data reader
    29.             Do While (myReader.Read)
    30.                 ' Each time through the loop represents one record being returned
    31.                 ' Put the email address from the data reader into the form
    32.                 txtOpenedFile.Text = txtOpenedFile.Text & myReader("Examiner") & vbCrLf
    33.  
    34.  
    35.             Loop ' End of Loop (any particular record)
    36.  
    37.         Catch ex As Exception
    38.             ' an error has occured execute the following
    39.             Debug.WriteLine(ex.Message)
    40.         Finally
    41.             ' Regardless of what happened this code will execute
    42.             ' Close the data reader
    43.             If Not (myReader Is Nothing) Then
    44.                 myReader.Close()
    45.             End If
    46.             ' Close the connection to the database
    47.             If (myOleDbConnection.State = ConnectionState.Open) Then
    48.                 myOleDbConnection.Close()
    49.             End If
    50.  
    51.             ' Memory Management / Garbage Collection
    52.             myReader = Nothing
    53.             myOleDbConnection = Nothing
    54.             myOleDbCommand = Nothing
    55.  
    56.         End Try
    57.     End Sub
    58.  
    59. End Class
    Thanks to any one who helps.
    Daisy
    Last edited by si_the_geek; May 29th, 2005 at 11:15 AM. Reason: added VBCode tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width