离线时本地存储数据的最佳方法
我正在编写一个小程序(更多的是与 2010 年相比进行实验)
尽管是一个实验,但它对我们当地的体育俱乐部有一些实际用途。
我的想法是访问数据库(当前在线)以下载当前会员并本地存储在笔记本电脑上(这是一个 MS sql 表,用于为俱乐部网站提供支持)。
将笔记本电脑带到活动现场(是的,有些地方没有互联网覆盖),向当天的比赛添加成员(也是 sql 表中的一行(尽管不会对此进行任何更改),记录结果(新记录在第三张表中)
回到家后,淋浴并再次访问互联网,根据比赛结果/成员更改等上传/编辑表格。
所以我想我应该做一些事情,比如使用数据在本地编写 xml 文件,包括一个字段指示更改等?
如果有人能指出我的方向,我将不胜感激......如果有人能告诉我这是否有名字,我将不胜感激。
I am in the midst of writing a small program (more to experiment with vs 2010 than anything else)
Despite being an experiment it has some practical use for our local athletics club.
My thought was to access the DB (currently online) to download the current members and store locally on a laptop (this is a MS sql table, used to power the club's website).
Take the laptop to the event (yes there ARE places that don't have internet coverage), add members to that days race (also a row from a sql table (though no changes would be made to this), record results (new records in 3rd table)
Once home, showered and within internet access again, upload/edit the tables as per the race results/member changes etc.
So I was thinking I'd do something like write xml files locally with the data, including a field to indicate changes etc?
If anyone can point me in a direction I would appreciate it...hell if anyone could tell me if this has a name, I'd appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
本质上,除了远程数据存储之外,您还需要桌面上的本地数据存储。然后,您可以手动编写代码以在离线/在线时同步数据存储,或者您可以使用 Microsoft Sync 框架 来为您处理它。
我个人在许多项目中使用过 Sync 框架,一旦您习惯了这些约定,它就非常容易使用。
Essentially what you need is, in addition to your remote data store, a local data store on your desktop. You could then write your code by hand to sync the data stores when you go offline / online, or you could use the Microsoft Sync framework to handle it for you.
I've personally used the Sync framework on a number of projects and once you get used to the conventions, it's pretty easy to use.
如果您想要本地存储格式。 SQLite 是一种选择。您可以将表从服务器复制到本地 SQLite 数据库。
您还可以将数据保存到文件中,但 XML 是一种糟糕的格式。您可能需要使用 YAML 或 JSON 代替。
If a local storage format is what your after. SQLite is one option. You can copy your tables from the server to your local SQLite db.
You could also save your data to files, but XML is a horrible format for doing this. You'll probably want to use YAML or JSON instead.
您可能想看看 SQL Server Compact——它提供了一些不错的功能,可以与母版 SQL 服务器同步。
You may want to take a look at SQL Server Compact -- it provides some decent capabilities with synchronizing back with the mothership SQL server.
如果您使用 MS SQL Server 进行生产,并且只需要在个人计算机上脱机工作,则可以安装 MS SQL Server Express 本地。与使用不同的本地数据存储相比,这里的优点是您可以重用架构、存储过程等。本质上只需要更改应用程序的连接字符串(您也可以通过 Visual Studio 在本地运行)。您必须编写代码来手动同步在线和离线数据库实例,但由于它是一个小型应用程序,因此将整个数据库从生产复制到本地,然后在您回家后从本地复制到生产可能是合理的(假设您是唯一更新数据库的,并且不会清除您在活动期间输入到生产中的任何新记录)。
If you're using MS SQL Server for production, and you only need to work offline on your personal computer, you could install MS SQL Server Express locally. The advantage here over using a different local datastore is that you can reuse your schema, stored procedures, etc. essentially only needing to change the connection string to your application (which you could run locally too through Visual Studio). You would have to write code to manually sync your online and offline db instances, but since it's a small application, it may be reasonable to just copy the entire database from production to local and then from local to production when you get home (assuming you're the only one updating the db, and wouldn't be potentially wiping out any new records entered in production while you were at the event).
如果您的应用是网络应用(即从你的描述中我不太明白它是什么)
Google Gears http://gears.google.com/ is intended if your app is a web app (which I didn't quite get what it is from your description)