Results 1 to 4 of 4

Thread: [RESOLVED] Irregular OleDbException: Cannot open database

  1. #1

    Thread Starter
    Hyperactive Member Quasar6's Avatar
    Join Date
    Mar 2008
    Location
    Sol 3
    Posts
    325

    Resolved [RESOLVED] Irregular OleDbException: Cannot open database

    Hey all,

    Using C# 2008, an Access 2003 *.mdb database, and a Microsoft.Jet.OLEDB.4.0 connection.

    I am building a program that monitors and queues tasks ultimately for around 40 users on the same Office LAN (at the moment I only have 7 users on it). The program adds these tasks to the Queue table of my database (hosted on the network), then creates a temporary file (also on the network). All the client programs periodically check for the existence of this file, and if they find it, run a few TableAdapter.Fill() commands to retrieve the data that was placed in the database.

    I am finding that, quite often but not so regularly that I can replicate it under controlled conditions, the program will either hang on the .Fill() command for a period of 10-20 seconds (confirmed to be hanging on that command specifically by pausing the debugger while it was happening), or it will throw the following exception:

    System.Data.OleDb.OleDbException: Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.
    at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
    at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
    at System.Data.OleDb.OleDbConnection.Open()
    at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
    at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
    at ModelManager.Model_ManagerDataSetTableAdapters.GeneralTableAdapter.Fill(GeneralDataTable dataTable)
    at ModelManager.Form1.Form1_Load(Object sender, EventArgs e)
    Would changing to a Microsoft.ACE.OLEDB.12.0 connection prevent this exception or keep it from hanging? Could anyone offer any suggestions as to what is causing either of these pheneomena (I assume it relates somehow to the spike in network traffic when a user makes a modification and all the other users run a Fill() command within 3 seconds, but googling the exception and the conditions surrounding it has turned up no valuble information)?

    Gratefully,
    Qu
    "Why do all my attempts at science end with me getting punched by batman?" xkcd.

    |Pong||
    Sorry for not posting more often.

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Irregular OleDbException: Cannot open database

    IMO You should change to SQL or change the design leaving out access from it

    JG

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Irregular OleDbException: Cannot open database

    File-based databases (such as .mdb files) are not designed to be used by multiple users at the same time.

    While you can use them in that manner, you will frequently get problems (such as the one you mentioned, and more), because any one user can easily lock everyone else out entirely.

    Changing providers might make a minor difference, but it will not solve the inherent cause of the problem.


    Switching to a server-based database (such as SQL Server Express/MySQL/Oracle/etc) will eliminate that kind of issue, and give extra benefits too - such as increased database size, ability to backup the database while it is being used, stored procedures, better security, etc.

  4. #4

    Thread Starter
    Hyperactive Member Quasar6's Avatar
    Join Date
    Mar 2008
    Location
    Sol 3
    Posts
    325

    Re: Irregular OleDbException: Cannot open database

    Thanks guys. I'll look into upsizing the database to an SQL server and see what I can achieve that way.
    "Why do all my attempts at science end with me getting punched by batman?" xkcd.

    |Pong||
    Sorry for not posting more often.

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