none
"Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt."

    Question

  • I'm receiving the following error message in a Visual C# application:

    System.Data.OleDb.OleDbException was unhandled by user code
      Message="Cannot open database ''.  It may not be a database that your application recognizes, or the file may be corrupt."
      Source="Microsoft JET Database Engine"
      ErrorCode=-2147467259
      StackTrace:
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
           at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
           at Daily_File_Analysis_Tool.fclsUpdateProcessedDailyFileDataBase.ProcessDailyFile(String strFilepath) in C:\Users\Tom\Desktop\DFAT_V4\Daily File Analysis Tool\Daily File Analysis Tool\fclsUpdateProcessedDataBase.cs:line 362
           at Daily_File_Analysis_Tool.fclsUpdateProcessedDailyFileDataBase.backgroundWorkerFiles_DoWork(Object sender, DoWorkEventArgs e) in C:\Users\Tom\Desktop\DFAT_V4\Daily File Analysis Tool\Daily File Analysis Tool\fclsUpdateProcessedDataBase.cs:line 106
           at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
           at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

    I'm sure the application recognizes the database since the error is occuring when I attempt to add a new record to a specific table after completing the addition of a record to another table, so the connection to the database is OK.  And the database is not corrupt, since I can open the database and inspect the tables with Access. 

     

    I suspect the problem is related to the size of one of the tables which currently has 4401383 records, but throws the exception when I try to add the 4401384th record. The index on this table is a string with a field size of 25. 

     

    Any suggestions would be appreciated.

    Saturday, May 17, 2008 10:46 AM

Answers

  • This looks like an Access database to me and it sounds like you're trying to exceed the maximum size, which just happens to be 2 GB.
    Monday, May 19, 2008 1:10 PM
  • Ah, you might have already given the answer. JET/Access databases are limited to 2GB. I don't know how many bytes/record you're consuming but a simple check of the filesize should reveal how large it is. If the rows are larger than 500 or so bytes (on the average) then the database is full.

     

    This has nothing whatsoever to do with SQL Server.

    Monday, May 19, 2008 9:47 PM
    Moderator

All replies

  •  TEAAssociates wrote:

    I suspect the problem is related to the size of one of the tables which currently has 4401383 records, but throws the exception when I try to add the 4401384th record. The index on this table is a string with a field size of 25. 

     

    What edition of SQL Server 2005 do you have?

     

    4M rows is not very large in view of today's capacities.

     

    Is that database online? Can you access it from SSMS?

     

    Also, are you using stored procedures for INSERTs, UPDATEs and other operations?

     

    Best Practice is using sprocs.

    Saturday, May 17, 2008 11:13 AM
  • I have whatever version of SQL Server that comes with Visual Studio 2005 Standard Edition.

     

    The database is not online, it is one that I have created.  It is currently about 2GB in size.

     

    I’m using a text command, not a stored procedure.  It isn’t clear to me how to create a stored procedure.

    The text of the INSERT INTO command is:

    INSERT INTO `Occupancies` (`OccupancyIndex`, `PortalIndex`, `Date`, `DailyFileFilename`, `OccupancyNumber`, `StartTime`, `StopTime`, `Speed`, `EstimatedVehicleLength`, `PrecedingGammaBackground_MU`, `PrecedingGammaBackground_ML`, `PrecedingGammaBackground_SU`, `PrecedingGammaBackground_SL`, `PrecedingNeutronBackground_MU`, `PrecedingNeutronBackground_ML`, `PrecedingNeutronBackground_SU`, `PrecedingNeutronBackground_SL`, `MaximumGamma_MU`, `MaximumGamma_ML`, `MaximumGamma_SU`, `MaximumGamma_SL`, `MaximumGamma_M`, `MaximumGamma_S`, `MaximumGamma_U`, `MaximumGamma_L`, `MaximumGamma_Total`, `MinimumGamma_MU`, `MinimumGamma_ML`, `MinimumGamma_SU`, `MinimumGamma_SL`, `MinimumGamma_M`, `MinimumGamma_S`, `MinimumGamma_U`, `MinimumGamma_L`, `MinimumGamma_Total`, `MaximumNeutron_MU`, `MaximumNeutron_ML`, `MaximumNeutron_SU`, `MaximumNeutron_SL`, `MaximumNeutron_M`, `MaximumNeutron_S`, `MaximumNeutron_U`, `MaximumNeutron_L`, `MaximumNeutron_Total`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

     

    Saturday, May 17, 2008 11:57 AM
  • This looks like an Access database to me and it sounds like you're trying to exceed the maximum size, which just happens to be 2 GB.
    Monday, May 19, 2008 1:10 PM
  • Ah, you might have already given the answer. JET/Access databases are limited to 2GB. I don't know how many bytes/record you're consuming but a simple check of the filesize should reveal how large it is. If the rows are larger than 500 or so bytes (on the average) then the database is full.

     

    This has nothing whatsoever to do with SQL Server.

    Monday, May 19, 2008 9:47 PM
    Moderator
  • Below is some additional info from the Access Team blog:

     

    http://blogs.msdn.com/access/archive/2006/06/05/access-2007-limits.aspx

     

     

    Monday, May 19, 2008 11:05 PM
  • I had the same issue in Access 2010 using .mdb database (old 2007 format).  I was importing an csv file that was approx 200mb in size, into a table.

    All tables in the database were empty to begin with, however, the database size was close to 2gb. When I did the import I got this error. This was even though all tables are empty.

    Maybe someone can explain, but it looks like the database retains a lot of data in the background even though the tables are empty, every time you use the database. My database has been used several times previously in the past without problems, but i think each time I have used it, the database size has increased... I am not sure why this happens.

    When the database was originally coded, the size of the database was approx 100mb. 

    I did find a way around it.. in 2010 Access, there is a feature called Database Tools -> Compress and Repair, and after running that it reduced the size of the database considerably, and hey presto, the problem was solved.

    (In case you are wondering why I am still using the .mdb format, is because i am running an old version of crystal reports off it, its a hangover from a long time ago.. and i am stuck with it for now.)

    I would like to know what data/objects the database is caching, and is there a cleanup routine to dump the cached data every time i exit the Access database?

    Best Regards

    Martin

    Tuesday, July 30, 2013 10:20 AM
  • Here's something else to consider.  I'm using VS2010 for an app which accesses a SQL server database plus a small local MDB file for temporary information for a WinForms App.

    I was getting the same "Cannot open database ''" error, but completely randomly (it seemed). The MDB file was less than 1Mb, so no issue with a 2Gb limit as mentioned a lot with this error.

    It worked 100% on 32 bit versions of windows, but I discovered that the issues were on 64 bit installations.

    The app was being compiled as "Any CPU".

    I changed the compile option from "Any CPU" to "x86" and the problem has disappeared.

    Hope this helps someone - we have spent 3 or 4 days off and on trying to track this down.

    Cheers

    David





    • Edited by d2 Saturday, September 07, 2013 12:16 AM
    Saturday, September 07, 2013 12:13 AM