views:

177

answers:

5

Hello,

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.

+1  A: 

ADO.NET in disconnected mode [PDF link] can be your starting point.

Learning
I think that this does not apply to what I've put on my EDIT2, isn't it?
SoMoS
A: 

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 think that this does not apply to what I've put on my EDIT2, isn't it?
SoMoS
A: 

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

Perpetualcoder
It is a standard WinForms application, not Web related.
SoMoS
Memento is the design pattern if thats what u wanted to know...so when in disconnected mode u have options like 1. Disconnected ADO.net as posted by Learning 2. Embedded RDBMS like SQLite 3. Embedded OODBMS like db40 or versant.
Perpetualcoder
In connected mode...client interacts directly with server. On disconnect u will need to save data in one of the 3 methods or just plain old .net serialization... on reconnection ur server software will need to be able to consume the data from local data store
Perpetualcoder
A: 

you may want to look into how google gears is designed

Aadith
Mmm, I think this has nothing to do with the problem explained here.
SoMoS
it does have things to do with the problem defined here. gears caches data from internet (which could be an online database) for offline access. users can make changes to data in offline mode and gears would synchronize with the actual source the next time connection is available.
Aadith
you could even consider the use of in-memory databases like SQLite that could act as cache to your main db. (in fact, that is how google gears works). there are standard ways of configuring in-memory DBs as caches to your main db
Aadith
Mmm, pretty interesant the information aboyt SQLite. Let me check it
SoMoS
+3  A: 

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.

Doc Brown
Database replication just adds data to the main server or replaces it? I need that everyone data gets added to the main DB server but not replaced. So I should replicate the main server at the local server on connection but just add data from local to main when there is data available.
SoMoS
If you want your application to have some restricted behaviour like "add only" in disconnected mode, you obviously have to deal with that in the user interface of your application, which is something your database cannot do for you.Have a look at MSDN here http://msdn.microsoft.com/en-us/library/ms151329.aspx, to learn more about SQL server merge replication and conflict resolution.
Doc Brown