为必须断开连接的数据库应用程序设计模式

时间:2021-01-30 11:11:09

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

PD:应用程序将在。net中完成

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

编辑:是WinForms应用程序,而不是Web应用程序。

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.

EDIT2:进入更详细的关于应用程序是在一个数据库输入数据,但有时用户将离开办公室几周,将需要输入数据,如果他们与从数据库缓存的数据输入和数据将被转移到数据库时再重新连接。

5 个解决方案

#1


3  

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).

您所描述的场景可以通过数据库复制来解决。例如,如果您使用MSSQL server作为您的主C/S db,那么可以将其复制到脱机用户工作站或笔记本上的本地MSSQL Express安装。只要您的用户不在办公室,应用程序就必须连接到本地数据库,当返回时,这些更改将复制回*数据库。我认为这是您正在寻找的“标准”方法,您不需要为脱机情况编写特殊的代码(除了更改连接的代码和启动复制的代码)。

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.

您可能会感兴趣的是,我们公司使用的CRM系统是这样工作的,使用的本地DB是“MSSQL desktop engine”,它是Express edition的前身,但是IMHO这应该也适用于Express edition。据我所知,您不必为MSSQL Express实例支付任何许可费。

#2


1  

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

ADO。NET在断开模式[PDF链接]可以是你的起点。

#3


0  

As answered already, ado.net is logical choice.

如前所述,ado.net是逻辑选择。

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

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.

当您再次使用DataAdapter连接更新数据库时,使用DataAdapter填充数据集(在内存中),在断开连接时使用该数据集。

#4


0  

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

我不确定你是否想要构建一个web或桌面应用程序,但Silverlight的浏览器功能也相当简洁。链接提供了一个很棒的起点。

#5


0  

you may want to look into how google gears is designed

您可能想了解谷歌齿轮是如何设计的

#1


3  

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).

您所描述的场景可以通过数据库复制来解决。例如,如果您使用MSSQL server作为您的主C/S db,那么可以将其复制到脱机用户工作站或笔记本上的本地MSSQL Express安装。只要您的用户不在办公室,应用程序就必须连接到本地数据库,当返回时,这些更改将复制回*数据库。我认为这是您正在寻找的“标准”方法,您不需要为脱机情况编写特殊的代码(除了更改连接的代码和启动复制的代码)。

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.

您可能会感兴趣的是,我们公司使用的CRM系统是这样工作的,使用的本地DB是“MSSQL desktop engine”,它是Express edition的前身,但是IMHO这应该也适用于Express edition。据我所知,您不必为MSSQL Express实例支付任何许可费。

#2


1  

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

ADO。NET在断开模式[PDF链接]可以是你的起点。

#3


0  

As answered already, ado.net is logical choice.

如前所述,ado.net是逻辑选择。

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

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.

当您再次使用DataAdapter连接更新数据库时,使用DataAdapter填充数据集(在内存中),在断开连接时使用该数据集。

#4


0  

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

我不确定你是否想要构建一个web或桌面应用程序,但Silverlight的浏览器功能也相当简洁。链接提供了一个很棒的起点。

#5


0  

you may want to look into how google gears is designed

您可能想了解谷歌齿轮是如何设计的