开发者

How do my users keep their sqlCE database in .NET application up-to-date?

开发者 https://www.devze.com 2023-02-10 10:05 出处:网络
I am having trouble with a concept. I am writing a c# quiz application, with the questions, answers and user profiles being stored in a sqlCE db, which is installed with the app. Users run the applica

I am having trouble with a concept. I am writing a c# quiz application, with the questions, answers and user profiles being stored in a sqlCE db, which is installed with the app. Users run the application, answering the questions in the database. However, they can also write their own questions, which should be available to other users of the same application after some sort of daily update.

What I cannot work out how to approach is the import and export of new question and answer data. I am a LAMP developer and am used to working with web MySQL databases, but have never worked with the db bundled in like this. The best I can think of is that users export a dump (csv perhaps) of their new question&answer set whihc gets uploaded to a master database in the cloud. To update their local database, they import a csv of the entire cloud-based db and empty their local database and insert 开发者_运维问答the contents of the csv.

It doesn't feel quite right this way. It's a small-time hobby app, not commercial; I'm really just trying to appreciate the process. Should I be looking at 'check for updates'?

Any pointers much appreciated, apologies for the non-specific nature of this question.


It depends on how and where your "master database" is located.

In this answer I assume you have a windows machine as server where you can install your own services as well as the database.

I would wrap the master database (probably a SQL Server Express Edition) behind a web service (WCF). The clients ask the web service for updates and sends new questions to the web service.
The web service would have at least two methods:

void AddQuestion(Question question);
Question[] NewQuestions(DateTime fromDate);

Those methods on the server would handle the saving of new questions and retrieving of new/updated questions in the master database. The client handles stores all questions in the local Compact SQL database.

Don't let the users handle extra tools and files to sync databases. Let the application do the job.


The SQL CE SDK comes with Client Agent, a DLL that performs remote replication with SQL Server. If your "master database" is SQL Server, and you are allowed to run IIS Server Agent against it, replication is built-in.

Note this performs Merge Replication. That is, differences between the local and remote database are compared, and statements that make the remote database match the server one are sent.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号