Sync Offline Database with External Database Windows Phone 7 - sql-server

I have a wp7 app that uses the local database implemented with linq. I have an external MS-SQL (2008 R2) server. Both databases have the same schema.
I would like to know how to do the following:
Download information from the MS-SQL to the Database into the local DB of the phone. (Can I use some data-binding technique - I have found no links that do this)
If Changes made on the phone (add new record, edit existing record) how can I push changes back to server.
If changes are made to server then push to phone (I know I can use an observer pattern here)
I should also note that the client app is not used always-on access to the internet.
Thanks

There's no magic here.
You will need to create functionality to get updates from the server (probably meaning you need some kind of timestamp on each record, saying when it was last changed so you can query it).
You will need to create the functionality to upload data and update the database on the server (and potentially handle conflicts).
I would either use ODATA to communicate with the server, or plain old WCF/JSON service.

have a look at the Sync Framework Toolkit

Related

Xamarin IOS/Android DOTMIM SYNC compatible with Azure Sql

I have an Xamarin cross platform application. I am currently storing my data in a Sqlite Database. However we want to have bi-directional syncing with an Azure Sql Database. After much reading I decided to give Dotmim Sync a try. The initial sync worked, however when adding a column to a table and attempting to migrate the data (following the tutorial), I got an error stating that the tracking table was missing. I redid everything again and realized that the entity tracking table was never created and I am not sure why. However Sql created a tracking table but it was not the entity tracking table that the error stated was missing.
I am curious if anyone with Xamarin has been able to successfully create bi-directional syncing with Sqlite and Azure Sql using Dotmim Sync. I have yet to find anything else that will work. Other than hand jamming it in this tutorial: https://www.xamarinhelp.com/mobile-database-bi-directional-synchronization-rest-api/
I am not against that, just seems like a lot of room for error. I am hoping someone out there has had success with what I am trying to do.
Hello I'm using Dotmim sync to synchronize a Sql Server database with a Sqlite database hotsted in a xamarin forms application through an API.
I think that I had the same problem as yours.
The problem is, as far as I understood, that the tracking tables are created only on the first sync.
If you change the schema of those tables you will need to call the Deprovision method.
This method will re-create the stored procedures and the triggers with the new database schema.
I'll leave you the link to the docs:
https://dotmimsync.readthedocs.io/Provision.html#provision-deprovision.

Best way to get Azure and local SQL Server development databases to sync on request

I'm looking for a one click system that doesn't require one to delete the Azure database, publish from the local server, and re-create the user info onto the deployment.
What currently works:
Drop existing Azure database.
MSDeploy the database to azure.
Move the database to the app pool
Configure Azure database user/access
I briefly looked into the Azure sync, but that doesn't seem like something one can use "on request". Do correct me with example if I'm wrong on this assumption.
The ideal solution would be a one button click from Azure Data Studio to push any and all changes from the (localdb) database to the live one.
Azure Data Studio doesn't provide any readymade Single Click data transmission feature from local to cloud or vice-versa.
Azure Data Studio offers a modern editor experience with IntelliSense,
code snippets, source control integration, and an integrated terminal.
It's engineered with the data platform user in mind, with the built-in
charting of query result sets and customizable dashboards.
It doesn't provide in-built data push feature. Either you should use any programming language to build a dashboard as per your requirement, or you need to use Store Procedure for it.

Windows Phone 7 databases

i am new to windows phone 7 and im just looking for some information in regards to databases.
I understand that we can use SQLce to store a database, i've got some idea on how to create one, at the moment i was wondering how to have prepopulated data when a app is loaded?, ive heard about sqlmetal is that a way of creating a database and addinbf data?
Also When i have a database on a mircosoft sql server, is it possible for SQLce and SQL server to pass data between each other i.e hold the same database with same data?
Also i believe that i must have a webservice for the phone to connect to the webserver how would i apporach this? would i use httprequest to connect to the webservice then the webservice connect/interact with the webserver what code would the webservice be written in?
Any links would be a great help
Sorry if its long winded
Thanks
There are some good tutorials available for how to use SQL CE - e.g. http://www.windowsphonegeek.com/tips/Windows-Phone-Mango-Local-Database(SQL-CE)-Introduction
For a pre-populated database, you might also want to check out http://blog.arsanth.com/?p=343
For synchronising databases and supplying a web service - I think this is for you to code - maybe consider an odata service - http://msdn.microsoft.com/en-us/data/aa937697
There are alternatives to sqlce - in particular at least a couple of sqlite ports and some wp7 specific stores like Stirling
It might be an idea to try starting on something and then come back to StackOverflow when you hit specific issues/problems.
Your SQL CE file can be shipped as part of your app. Set the df file to COntent in the Solution View and create a DataContext with the appropiate connection string. MIne looks like
DataContext ctx = new DataContext("Data Source=appdata:/DataModel/Database.sdf;Mode=Read Only")
To create Have a read through Converting SQL Server database to local C# database and it points to http://www.codeproject.com/Articles/25685/SQL-Server-to-SQL-Server-Compact-Edition-Database to create a SQLCE database from SQLServer database.
In most cases you don't need a relational DB
Maybe you should look into Sterling, Raven, fileDb or any other nosql that suits for silverlight

Drupal 7 webform submission to remote MSSQL server

When users fill up a form on my Drupal 7 site, I need that information to go into a remote MS SQL server db. It's essentially a reservation system, so they fill up details like date/time and name, and when they click submit, these fields need to be pushed into a remote MS SQL db.
I'd like to know a) if this is possible and b) how do I go about implementing this?
A. Yes it is possible.
B. I recommend the below way, which is also the "Drupal" way of doing it.
Establish a connection to the remote database. Have a look here if you want to do it in your code, or have a look here if you want Drupal to take care of it by configuring settings.php. The key to switching between databases are db_set_active($database).
Run the queries you'd like to run against the MSSQL database. Just remember to put switch between the databases using db_set_active().
You can create a custom form in Drupal easily using its Form API in a custom module. In the submit handler for your form, you can insert the submitted data to your MS SQL database using any library avaiable in your PHP environment. Connection to the database is the tricky part, especially if your Drupal host is not running a Microsoft OS. In Drupal 7 running on IIS, you can use Drupal's Database API with the MS SQL driver. If your are not on IIS or Drupal 7, this is also doable without Drupal's Database API using PDO ODBC with unixODBC and FreeTDS. I did it, but I had a major issue when using typed bound parameters in my query, see Using typed bound parameters with PHP PDO-ODBC, unixODBC and FreeTDS.
That said, integration of applications at the database level is a bad idea. Such integration is tightly coupled. Any change to the schema of your MS SQL database or they way actual data are stored in columns will break your form submission. The best would be to have your reservation system provides a remote API to insert new data.

Suitable method For synchronising online and offline Data

I have two applications with own database.
1.) Desktop application which has vb.net winforms interface, runs in offline enterprise network and stores data in central database [SQL Server]
**All the data entry and other office operations are carried out and stored in central database
2.) Second application has been build on php. it has html pages and runs as website in online environment. It stores all data in mysql database.
**This application is accessed by registered members only and they are facilitied with different reports of the data processed by 1st application.
Now I have to synchronize data between online and offline database servers. I am planning for following:
1.) Write a small program to export all the data of SQL Server [offline server] to a file in CVS format.
2.) Login to admin Section of live server.
3.) Upload the exported cvs file to the server.
4.) Import the data from cvs file to mysql database.
Is the method i am planning good or it can be tunned to perform good. I would also appreciate for other nice ways for data synchronisation other than changing applications.. ie. network application to some other using mysql database
What you are asking for does not actually sound like bidirectional sync (or movement of data both ways from SQL Server to MySQL and from MySQL to SQL Server) which is a good thing as it really simplifies things for you. Although I suspect your method of using CSV's (which I would assume you would use something like BCP to do this) would work, one of the issues is that you are moving ALL of the data every time you run the process and you are basically overwriting the whole MySQL db everytime. This is obviously somewhat inefficient. Not to mention during that time the MySQL db would not be in a usable state.
One alternative (assuming you have SQL Server 2008 or higher) would be to look into using this technique along with Integrated Change Tracking or Integrated Change Capture. This is a capability within SQL Server that allows you to determine data that has changed since a certain point of time. What you could do is create a process that just extracts the changes since the last time you checked to a CSV file and then apply those to MySQL. If you do this, don't forget to also apply the deletes as well.
I don't think there's an off the shelf solution for what you want that you can use without customization - but the MS Sync framework (http://msdn.microsoft.com/en-us/sync/default) sounds close.
You will probably need to write a provider for MySQL to make it go - which may well be less work than writing the whole data synchronization logic from scratch. Voclare is right about the challenges you could face with writing your own synchronization mechanism...
Do look into SQL Server Integration Service as a good alternate.

Resources