I'm not sure if this should be posted in VB.NET, Databases, or MS Office. But let's see...

I have an app (written in VB 2005) that accesses an MS Access database.

I have 2800+ text files to process and write to this database. They each have a unique number in their names, so it's just a matter of parsing it to check for the entry in the table. Unfortunately, the numbers are not sequential, and range from 60 to 19910.

So i need to check for a record for each one prior to processing it. If the record exists, I update its information.

Now, here is the problem:

After about, oh, 14000 times (and that's an estimate, I'm not really sure where it started), I begin getting the error 08004:Too many client tasks. on conn.open()

The breakdowns seem to occur progressively quicker (that is, for example, at 200, 250, 278, 290, 295 etc. (not actual number examples).

I can limp past it by doing a try block with a conn.close() then conn.open() in the catch block. But that's cludge, and it only works for a while, then I get the same error in the Catch block. I can move back to conn.close() and continually try F5 until it works. But it's an ugly thing to have to do.

If I stop debugging (this is all in the IDE, and thankfully not compiled) and start over with the next number in the series, it works for a while, then breaks again.

Code:
    Function NotInDatabase(ByVal ReportNumber As Integer) As Boolean
        Dim conn As OdbcConnection
        Dim comm As OdbcCommand
        Dim dr As OdbcDataReader
        Dim connectionString As String
        Dim sql As String

        connectionString = "DSN=MS Access Database;DBQ= " & DATABASE_LOC
        sql = "SELECT ReportNumber FROM Reports WHERE ReportNumber = " & ReportNumber
        conn = New OdbcConnection(connectionString)

        conn.Open()         ' <== Error 08004: Too many client tasks

        ' shamefull attempt to fix
        'Try
        '    conn.Open()
        'Catch
        '    conn.Close()
        '    conn.Open()
        'End Try

        comm = New OdbcCommand(sql, conn)
        dr = comm.ExecuteReader()

        Try
            dr.Read()
            If dr.GetInt16(0) = ReportNumber Then
                Return False
            Else
                Return True
            End If
        Catch
            Return True
        End Try

        conn.Close()
    End Function
I do access the database in another procedure, with similar code:
Code:
    Sub UpdateRecord(ByVal ReportNumber As Integer, ByVal FieldName As String, ByVal FieldValue As String)
        Dim conn As OdbcConnection

        Dim connectionString As String
        Dim sql As String
        connectionString = "DSN=MS Access Database;DBQ= " & DATABASE_LOC
        sql = "UPDATE Reports SET " & FieldName & " = '" & FieldValue & "' WHERE ReportNumber = " & ReportNumber

        conn = New OdbcConnection(connectionString)
        conn.Open()

        Dim cmd As New OdbcCommand(sql, conn)

        cmd.ExecuteNonQuery()
        conn.Close()

    End Sub
but it never breaks in this here. I include it to show that I do, indeed, close the connection everywhere.

BTW, I did limp all the way through to the end. I got all the files processed. But it was hellish, and I will eventually have to do this again. I can't find the answer elsewhere, and I've little doubt that if it happened to me it'll happen to someone else.