Data Sync for Universal Windows App(desktop) Sqlite - c#

I am currently working on a windows universal app project(deskptop App), what i want to do is store data in my uwp app using sqlite database and be able to sync this data to a sql database located on azure, i went came across this online
https://blogs.msdn.microsoft.com/sync/2010/08/31/sql-server-to-sql-azure-synchronization-using-sync-framework-2-1/
but it seems applicable to sqlcompact and sql to sql on azure.
Please can any one help wiith how i can sync my uwp sqlite database with sql database on azure.Thank you

how i can sync my uwp sqlite database with sql database on azure.
You could use Azure app service. The mobile apps have the "Offline sync" feature:
You can sync dataset automatically with the back-end data, including conflict-resolution support.
For more details about "Offline sync" please reference this document.
For how to create a UWP mobile app please reference this article.
In your scenario, since you already have a SqlServer on azure, so when you are following the tutorial, after created the backend, in the step of Configure the server project, you can instead choose "Use an existing database".
After the client mobile app created successfully, then you need to Enable offline sync for your Windows app. The sample just showed how to use the SQLite as the local store. Using PushAsync method to push tables to the backend which is configured the SQL Server to meet your requirements.

Related

Xamarin get/insert data from MySql hosted on another PC

I want to building an android app by Xamarin, C# language. This app can get or insert data to MySQL, this SQL hosted on another PC
So, Where I can get information and tutorial for this?
Thank you!
Basically if your MySQL database is in another computer, you need to communicate to it over web, I would suggest you use API, in computer with database make API Application.
https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-5.0
There is microsoft documentation for it.
Create endpoints for specific actions, and then communicate with them from your Xamarin App, here's the documentation: https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client
Create API service on computer with database
Communicate from your application to API (then API communicates with database, and sends back results to your Xamarin App)
I personally like RESTful principles for API's. documentation: https://restfulapi.net/
You should also consider adding authentication to API, so that only apps you want, can GET/INSERT data to your database
to get data from mysql in any app you need to API:
i using ASP webservice to get data from mysql
then in Xamarin.Android APP in refrence folder click right and add web refrence .
watch this video :
https://www.youtube.com/watch?v=XTZ8pbWAVW4&list=PLF8OvnCBlEY3qYheTm4gnaoWwBuBf2TUj&index=46

Set up MySQL back-end in Azure for Xamarin Offline Sync

I have a MySQL database set up through the Azure Portal, currently hosted on ClearDB. I have created a mobile app using Xamarin Forms that implements an SQLite database which stores relevant information for my app in it. I am implementing offline sync functionality using the Microsoft.WindowsAzure.MobileServices.SQLiteStore library, and I am using functions such as:
await table.ToListAsync();
await table.UpdateAsync(entry);
await client.SyncContext.PushAsync();
await table.PullAsync("allEntry", table.CreateQuery());
The last thing I need to do is sync my local SQLite database with the Azure cloud MySQL database I have created. How do I implement this in C# (or Node.js .. or ANY language) such that my SQLite database can sync entries with my Azure MySQL database.
Thanks!
According to your requirement, I tried to create my Azure Mobile App project via Visual Studio, and install MySql.Data.Entity 6.9.9 which supports MySQL for EF6, then create my table controller working with my DBContext for MySQL.
I created my db model that inherits the EntityData which contains the table column type DateTimeOffset, but I encountered a incompatible error message. Then I found there is a known bug in MySQL Connector as follows:
An Entity Framework DbContext object created with a column of type DateTimeOffset returned an error indicating that DateTimeOffset values were incompatible with DateTime and Timestamp values. (Bug #24732001)
I found a release note about MySQL Connector/NET, then I tried to upgrade to MySql.Data.Entity 7.0.7-m61, but another problem about TypeLoadException - MySqlEFConfiguration encountered.
Since your goal is to use offline sync for your Xamarin app with azure mobile app, I recommend that you could try to use sql database or azure table storage for your data storage instead of MySQL, which could build your mobile app backend in a simple way. You could refer to here for getting started with it.

Connect to MS Access Database with android

I'm working on a project and I need to connect to MS Access Database. The problem is that I'm using a pretty new platform , I'm using Visual Studio 2015 Xamarin and I'm developing to android with c# (thought this platform).
I already have a project with this Database using aspx and i need to connect the android application to this Database .
I could not find any answer for it , probably cause it's new .
Thanks for helping.
The problem is not related only to Xamarin or MS Access.
Everytime you want to use the same database in different applications (in your case a website and mobile apps), it is better to create a new layer (WCF Service or REST API) in order to access the same database on the server. This is more flexible and would be the right thing in your case.
Without moving the architecture to the next Level, you will always have such problems when mixing old and new technologies together.
If you just want to finish this quickly for school and use the database only on the device, then there is no way to use the MS Access database with xamarin. I recommend using SQL lite for this and there are lots of examples for that:
https://developer.xamarin.com/recipes/android/data/databases/sqlite/
It not clear if the database is to run “local” on the android, or you just wishing to connect to some web service that holds the database?
If you needing a local database to run 100% stand-alone on the Android device, then Access is not supported. Your best bet for a local database would thus be SQLite.
Perhaps you don’t need nor want a local data store. In this case if the Access database is on the server, then you would be forced to write some kind of web service to “interact” with your Android software and the web server (this would not be a "general" interface to the database, but a set of web services that you expose on the web site - this assumes you thus have control and are able to write software and implement a web service on the web site. So in this case some kind of “direct” connection to the Access database is not possible.
You could again certainly DIRECTLY connect to a server based database like SQL server – but this would assume the web hosting allows external ODBC connections to the database (often they don’t allow this, but some do).
So not clear is if you need a local database running on the Android that can THEN connect to some web or server based system, or you simply want the android to connect via the internet to some database hosted on some server and the Android device does not have a local database at all.
Regardless of the location of MSAccess, you cannot "connect" to a non server database like Access. So the question remains as to "where" you want this database to be used, and ALSO if you need a local data store on the Android device or not.

How to access local sqlite database of android application from .NET application

I want to synchronize android app database with central sql server database.
I currently working on .NET web services,Web service should update remote android database after every 10 minutes.I am not getting exact way.how to do this? I have developed web service but getting error of unable to open database while accessing remote database.
Is it possible to update remote sqlite database from .NET webservices?
please help me.Is there any other solution?
You need to add the parameter Legacy Format=True to your connection string.
Take a look at https://www.connectionstrings.com/sqlite/ under "Using the pre 3.3x database format."

Connect Visual Studio with Web Server

I made account with a hosting service and they give me sql username, password and hostname... then I created database, created table and inserted some data. Now I want to connect it to my program (windows phone 7.1) by using Microsoft Sync Framework. Can someone help me with that?
When I go to database explorer and press add connection I see these options but don't know which to use:
Microsoft Access Database File
Microsoft SQL Server Compact 3.5
Microsoft SQL Server Database File
this here should help you:
http://blogs.msdn.com/b/wriju/archive/2011/08/01/windows-phone-7-using-local-database-for-application.aspx
Your thinking about the Mobile Platform like it is Windows 7, The Mobile platform deals with Data differently and that blog post should help you understand.
Wp7.0 = Isolated Storage
Wp7.1 = Database, This data base is accessed via Linq.

Categories