If this is your first visit, be sure to
check out the
FAQ
by clicking the
link above. You may have to
register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
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,
"Why do all my attempts at science end with me getting punched by batman?"
xkcd.
|
Pong
|
|
Sorry for not posting more often.
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.
"Why do all my attempts at science end with me getting punched by batman?"
xkcd.
|
Pong
|
|
Sorry for not posting more often.
Advertiser Disclosure:
Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.