Is it possible to achieve this?
Download/fetch data from the database then save locally to a Windows Mobile app for later use (without internet connection).
Make changes to the database locally.
Upload the changes of the local database to update the database from the server manually.
I am thinking about a sync function but I am using an Oracle Database on the server and Oracle DB and SQL Server Compact doesn't support syncing with each other naturally.
Sure this is completely possible, but you are going to need to write the syncing feature yourself unfortunately. You might be able to incorporate this, but as of now there is no bolt-on solution for you, so you would need to add the syncing features.
Happy coding!
Please read about the ADO.NET technology.
It was made for implementation of your scenario - maintaining of disconnected cache of server data.
For example look at this article
And here is more specific example -> Disconnected Architecture in ADO.NET
Here's a great walkthrough from Microsoft on doing exactly this:
Walkthrough: Creating an Occasionally Connected Smart Device Application
Note that it was reported that this technique is not 100% reliable, meaning it can "forget" to post the latest data.
To get around this, you can add a TimeStamp DateTime field to each table that stores the time the latest data was written or updated, then modify your queries to only pull/push the latest records.
Related
I need your help to manage an issue with my C# program. I wrote a GUI that allows the user to manage a lot of data stored in a SQL Server database. Everything works fine but I want to be sure that the application works even when the server is down (for a generic issue).
My plan is to have a local database (e.g. *.mdf database used in Visual Studio) and update it every time the GUI is able to connect to the online SQL Server database.
What do you think? Is there something similar to a procedure or do I need to do it manually (create a .mdf file, check the online version, write the changes etc.)?
Apart from the comments noting that this may not be a good idea (which I agree):
Most of the work must be done manually. If you have a DB model within your application (like when using entity framework) it could be that it can create the DB structure in the local file. Most of your data will need timestamps to determine when they were changed the last time.
The Microsoft Sync Framework might utilize you but I have not used it personally. Look here http://msdn.microsoft.com/en-us/library/bb902854(v=sql.110).aspx
I know there's a lot of material on this topic, but somehow I really can't find anything not out of date and for my needs.
What I need.
I have a local SQL Express 2008 R2 Database
I need to sync this Database over WCF with a Server Database (SQL 2008 R2)
I ONLY NEED ONE WAY "DOWNLOAD" SYNCHING meaning, that the client Database is always overridden by the Servers.
How can I accomplish that?
I am trying for several days to get it work with the Microsoft Sync Framework 2.1.
Thank you!
have you looked at this sample?
Database Sync:SQL Server and SQL Express N-Tier with WCF
If you really won't need any data to go back into your server database from the client, then using MSF2.1 is overkill for what you need. It would probably be faster and easier to build (or find) a tool that makes an "insert or update" stored procedure for every table in your database. With that in place and the proper timestamps and delete flags in every table, you should be able to accomplish it with significantly less overhead than implementing the sync framework.
Also, if you haven't already taken a look at it, have a look at the web sync replication option: http://msdn.microsoft.com/en-us/library/ms151763.aspx
My requirement is to create a windows mobile 6.1 app [for a window PDA] that works most time in offline, and when it has connection it should work online to synchronize the data from PDA to server and server to PDA to keep the local and central database up to date.
There will be lots of transactions inside PDA and online too.The app will run more than one PDAs. So there will be lots of transactions in every PDA and it should sync with the central server when it is online.
How can I achieve this? Can I use microsoft synch service to do it? or any better other methods to solve it?
Short answer is yes, you can use Microsoft Sync Framework to do it.
However, quoting word to word from microsoft,
The major disadvantages to this solution are:
Changes are required in the central database schema to add columns
and tables that may affect current applications.
Triggers are fired
for each change made to a row, which has performance implications.
Logic for maintaining proper rowversions and row deletions can get
extremely complicated.
Long running transactions can result in some
data being missed during synchronization, resulting in data
inconsistencies.
You are in very much luck if the master database is in SQL Server 2008 though. Read "Challenges of Building an OCA" section in the article because there's no point in pasting everything here :)
I have deployed plenty of software to my clients. Mostly are Window Forms applications.
Here is my current practice.
Manually install SQLExpress and SQL Management Studio to each client PC.
Then use ClickOne to install the code from the server.
When there is a changes in code, I will use ClickOne to deploy -(NO PROBLEM with this step)
But when there is a change in a database column, what do I do?
I have even tried writing a database update script. Each time the program starts, it will read through the .sql update file and run them if the database exists. This solves the problem of updating the database columns, but it does not help in my DEBUGGING work when my customer complain there is a wrong data. At that point, I have to personally go to their site to check it out.
I find it difficult to have the database installed on the client PC as it make my debugging work very very difficult. I am thinking about moving my client database to a host on an Online server. But that then comes with these constraints:
What if the internet is down?
What if my customer has no internet?
Could you help to advise me? Is this a common problem faced by developer? What is the common practice out there? Does Window Azure or SQL CE help?
Depending on the data I would recommend using SQL CE.
If the data isn't too much, speed is not the primary goal (CE is slower than Express) and you don't need DB-Features not supported by CE (e.g. stored procedures) it is the better choice IMHO, because:
The client does not need to install a full SQL server (easier installation/deployment)
You do not have problems with multiple SQLExpress instances
Your SW doesn't need to worry if there even is a SQL instance
Less resources used on the client side
Additionally the clients could send you their SQL CE DB-File for inspection and you do not need to go to their site.
It is also relativly easy to implement an off site sync with SQL CE and MS Sync FW.
Installing one database per client PC can be tricky. I think you have a decent handle on how to deal with the issue currently. It seems like the real issue you are currently facing is debugging. To deal with this, there are a couple ways you could go:
Have the customer upload their copy of the database back to you. This would provide you with the data they have and you could use it with a debug copy of your code to identify the issues. The downside is that if the database is large it might be an issue transferring it.
Remote onto the customer's machine. Observe the system remotely using something like CoPilot. That way you could see what is happening in its natural environment.
There are probably other ways, but these are a couple of good ones. As for using an online database, this is an option but it brings its own set of issues with it. You mentioned a couple. As for Azure, that is cloud-based (online) so the same issues will apply. SQL CE won't help you any more than your current installation does.
Bottom line is that I would recommend you look into the ways to fix your one issue (as listed above) instead of creating a whole new set of issues by moving to an Internet-based solution. I would only recommend moving to the Internet if it was addressing a larger business need (for example, mobility). Doing the same thing you have been doing only online will probably just make life harder.
To recap the comments below since they are so pertinent to the issue, if you are choosing between file-based databases that don't need to be physically installed on the machine, your best choices are probably between SQLite and SQL CE. Microsoft supports SQL CE better but it is a larger package and has less features than the trim SQLite. Here is a good discussion on the differences:
https://stackoverflow.com/questions/2278104/sql-ce-sqlite-what-are-the-differences-between-them
However, the issue gets more complicated when you start looking at linq2sql since that is designed for SQL server. Microsoft does not support SQL CE with linq2sql out of the box, although there is a work-around that will get it to work:
http://pietschsoft.com/post/2009/01/Using-LINQ-to-SQL-with-SQL-Server-Compact-Edition.aspx
SQLite is not supported at all with linq2sql but there is a way to use linq to talk with SQLite:
LINQ with SQLite (linqtosql)
This library also supports other common databases including MySQL and Firebird.
You could use the SQLCMD utility to execute the change script, as mentioned in this related question
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.
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.
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.
You may want to take a look at SQL Server Compact -- it provides some decent capabilities with synchronizing back with the mothership SQL server.
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)