none
System.Data.OleDb.OleDbException (0x80004005): Cannot open any more tables. RRS feed

  • Question

  • I am running Win 7 64 bit, but developing 32 bit applicaition

    This application is using Jet engine and Access database.

    After few dozens reads I am getting the following error

    System.Data.OleDb.OleDbException (0x80004005): Cannot open any more tables.

    Here's my code.

            public DataSet LoadDataOleDb(string query, string tableName, OleDbParameter[] parms)
            {
                var ds = new DataSet();

                try
                {
                    _oledbAdapter = new OleDbDataAdapter();

                _tsrConnection = new OleDbConnection(_connectionString);
                _tsrConnection.Open();


                    _oledbAdapter.SelectCommand = new OleDbCommand(query, _tsrConnection);
                    _oledbAdapter.SelectCommand.Parameters.Clear();

                    foreach (var p in parms)
                    {
                        _oledbAdapter.SelectCommand.Parameters.Add(p);
                    }

                    _oledbAdapter.SelectCommand.Prepare();
                    _oledbAdapter.Fill(ds, tableName);
                    _oledbAdapter.Dispose();
                }
                catch (Exception e)
                {
                    throw new Exception(string.Format("{0}: {1}{1}", query, Environment.NewLine), e);
                }

                return ds;
            }

    Does anyone know how to fix this problem ?

    Thank You

    Peter


    Peter

    Tuesday, November 27, 2012 6:32 AM

Answers

  • OK, because the exception is indicating that the number of TableIDs (for open tables) has exceeded the maximum (2048). That would indicate to me that the tables are not being closed or there is some operation that is opening a very high number of tables.

    Edit: Updated the TableID limit.


    Paul ~~~~ Microsoft MVP (Visual Basic)


    Tuesday, November 27, 2012 5:30 PM
  • Just another suggestion, try compacting the database to see if it makes any difference.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by Alexander Sun Friday, December 7, 2012 1:35 AM
    Tuesday, November 27, 2012 5:37 PM

All replies

  • Have you tried closing the database connection (_tsrConnection) once the query has finished?

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Tuesday, November 27, 2012 2:42 PM
  • Yes I have and it does not make any difference.

    Peter

    Tuesday, November 27, 2012 2:44 PM
  • OK, because the exception is indicating that the number of TableIDs (for open tables) has exceeded the maximum (2048). That would indicate to me that the tables are not being closed or there is some operation that is opening a very high number of tables.

    Edit: Updated the TableID limit.


    Paul ~~~~ Microsoft MVP (Visual Basic)


    Tuesday, November 27, 2012 5:30 PM
  • Just another suggestion, try compacting the database to see if it makes any difference.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by Alexander Sun Friday, December 7, 2012 1:35 AM
    Tuesday, November 27, 2012 5:37 PM