简体   繁体   English

最佳方法是在离线时在本地存储数据

[英]Best means to store data locally when offline

I am in the midst of writing a small program (more to experiment with vs 2010 than anything else) 我正在编写一个小程序(更多的是试验vs 2010而不是其他任何东西)

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). 我的想法是访问数据库(目前在线)下载当前成员并在笔记本电脑上本地存储(这是一个MS sql表,用于为俱乐部的网站提供支持)。

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) 带上笔记本电脑参加活动(是的,有些地方没有互联网覆盖),添加成员参加那天的比赛(也是一个来自sql表的行(虽然不会对此进行任何更改),记录结果(新记录)在第3表)

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? 所以我想我会做一些像在本地写入xml文件的数据,包括一个表示更改等的字段?

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. 如果有人能指出我的方向,我会很感激...如果有人能告诉我这是否有名字,我会很感激。

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. 然后,您可以手动编写代码以在脱机/联机时同步数据存储,或者您可以使用Microsoft Sync框架为您处理它。

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. 我个人在许多项目中使用了Sync框架,一旦习惯了这些约定,它就非常容易使用。

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. 如果您正在使用MS SQL Server进行生产,并且只需要在个人计算机上脱机工作,则可以在本地安装MS SQL Server Express 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). 这里使用不同的本地数据存储区的优点是,您可以重用模式,存储过程等,基本上只需要将连接字符串更改为您的应用程序(您也可以通过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). 您必须编写代码来手动同步您的在线和离线数据库实例,但由于它是一个小型应用程序,因此在您回家时将整个数据库从生产复制到本地,然后从本地复制到生产可能是合理的(假设您'是唯一更新数据库的人,并且在您参加活动时不会消除在生产中输入的任何新记录)。

If a local storage format is what your after. 如果本地存储格式是你的后。 SQLite is one option. SQLite是一种选择。 You can copy your tables from the server to your local SQLite db. 您可以将表从服务器复制到本地SQLite数据库。

You could also save your data to files, but XML is a horrible format for doing this. 您也可以将数据保存到文件中,但XML是一种可怕的格式。 You'll probably want to use YAML or JSON instead. 你可能想要使用YAMLJSON

您可能想看一下SQL Server Compact - 它提供了一些不错的功能,可以与母舰SQL服务器同步。

Google Gears http://gears.google.com/旨在让您的应用成为网络应用(我的描述并不完全明白)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM