如何在Windows窗体应用程序中使用SQL数据库实现联机/脱机模式? [英] How to implement an online/offline mode with an SQL database in a Windows Forms application?

查看:70
本文介绍了如何在Windows窗体应用程序中使用SQL数据库实现联机/脱机模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是


我有一个Windows窗体应用程序,它显示在线数据库中的表格,并允许用户查看和更改数据库。我在项目设置中有到联机数据库的连接字符串,当加载Windows窗体时,它将
将相应数据库表中的数据加载到TableDataGridView对象和其他一些对象中。

Hello,

I've got a Windows Forms application that displays tables from an online database and allows the user to view and make changes to the database. I have the connection string to the online database in the project settings, and when a Windows Form loads, it loads the data from the corresponding database tables into the TableDataGridView objects, and some others.

我希望能够添加离线模式,这样当用户离开互联网时,他们仍然可以看到数据库在上次连接时的状态,并随意进行更改。当他们重新连接到互联网时,他们的更改将被
同步到主要在线数据库。



我对这类事情缺乏经验,我不确定如何进行离线模式。目前,一旦用户没有连接到互联网,程序在尝试加载窗口时会抛出错误,因为它试图从在线数据库表加载数据
以用数据填充TableDataGridView对象,并且它不能。



有没有办法在用户离线时保存在线数据库的快照,然后让连接字符串指向该快照而不是,当他们回到网上时以某种方式让它同步?



如果您需要更多信息,请告诉我们!



非常感谢您花时间阅读我的帖子!

I'd like to be able to add an offline mode, so that when the user is away from the internet, they can still see the database as it was when they were last connected, and make changes as they please. When they reconnect to the internet, their changes will be synced to the main online database.

I'm pretty inexperienced with this sort of thing, and I'm not sure how I would go about making the offline mode. Currently, as soon as the user isn't connected to the internet, the program throws errors when it tries to load windows as it's trying to load data from the online database tables to fill in the TableDataGridView objects with data, and it can't.

Is there some way to save a snapshot of the online database as the user goes offline, and then have the connection string point to that snapshot instead, and then somehow have it sync when they come back online?

Please let me know if you need any more information!

Thanks so much for taking the time to read my post!

推荐答案

您好,

查看 Microsoft Sync Framework

一个代码示例
网络。

我们的应用程序使用断言和提示继续或离线。每个用户的数据都是特定的,并自动下载。在没有互联网连接的现场,他们可以工作,回到办公室并按下同步按钮,因为他们不想要
自动同步。因此,部分原因是要了解您的业务需求,与他们合作。如果远程数据库可能有需要推送的更改,则可能会有一个程序提醒用户他们与
交互的数据已更改并要求他们执行同步。我发现在我的业务范围内,用户不关心强制性之外的自动同步。

Our applications use assertion and prompts to go on or offline. Data for each user is specific and downloaded automatically for them. In the field w/o a Internet connection they do work, come back to the office and press a sync button as they don't want auto sync. So part of this is saying is know your business requirements, work with them. If there cases where ther remote database may have changes that need to be pushed you could have a procedure that alerts users that data that they are interacting with has changed and ask them to perform a sync. I've found that in my line of business that users don't care for auto sync'ing outside of mandatory ones.

还要考虑制作快照和互联网时会发生什么连接丢失。

Also consider what happens when a snapshot is being made and a Internet connection is lost.


这篇关于如何在Windows窗体应用程序中使用SQL数据库实现联机/脱机模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆