Design pattern for a database application that must work disconnected

I have to design an application is mostly an interface with a database for data entry. The application must be able to work while it is disconnected from the database with cached data and insert that data when it has connection again. There will be two different modes, connected or disconnected, no need to detect disconnection in the middle of a connected session to switch to disconnected.

As this seems to me a common requisite i was wondering if there is a "standard" approach to face this problem. Caching tables to local file, serializing the data queried to the database or whatever. Maybe there is an existent library for doing that?

Thanks in advance.

PD: The application will be done in .Net

EDIT: Is a WinForms application, not a Web one.

EDIT2: To enter more detail about the application it is to enter data at one database, but sometimes users will be out of office several weeks and will need to enter data as if they were connected with cached data from the database and this data entered will be transfered to the database when they reconnect again.


The scenario you are describing can be solved by database replication. For example, if you are using MS SQL server as your main C/S db, it can be replicated to a local MSSQL Express installation on your offline users workstation or notebook. As long as your users are out of office, the application has to connect to the local DB, and when coming back, the changes are replicated back to the central DB. I think this is the "standard" approach you are looking for, where you don't have to write special code for your offline situation (except for the code that changes the connection, and some code to start the replication).

It might be of interest for you that the CRM system used by our company works just like this, the local DB used is "MSSQL desktop engine", the predecessor of the Express edition, but IMHO this should work with the Express edition, too. As far as I know, you do not have to pay any licence fees for the MSSQL Express instances.


ADO.NET处于断开模式[PDF链接]可以作为您的出发点。


As answered already, ado.net is logical choice.

http://msdn.microsoft.com/en-us/library/aa719836%28VS.71%29.aspx

Using DataAdapter fill DataSet (in memory), use that DataSet while you are disconnected, when you connect update database using DataAdapter again.

链接地址: http://www.djcxy.com/p/44132.html

上一篇: 试图了解为什么OpenMP代码不平行

下一篇: 数据库应用程序的设计模式必须断开连接