开发者

Design pattern for a database application that must work disconnected

开发者 https://www.devze.com 2022-12-17 13:40 出处:网络
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

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 conn开发者_StackOverflow社区ected 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 in disconnected mode [PDF link] can be your starting point.


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.


I am not sure if you want to build a web or desktop app but Silverlight's out of browser features are pretty neat too. Link provides an awesome starting point


you may want to look into how google gears is designed

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号