Reputation: 558
I just got started with third year in my Computer Science degree and I really loved making ASP.Net websites, but now I am interested in learning Xamarin
Android applications and make those applications database to be available as a Azure SQL database
.
I've learned to make the Azure SQL Database
and use the SSMS
to make the tables and develop the ASP.NET
locally and deploy them in Azure and I was thinking it might be the same with Xamarin, but apparently, I am wrong. So here are my questions and it will be great if someone could help me with it.
1) Why can't I use SqlConnecton
classes inside Xamarin.Android's
cs classes?
2) Is there a different approach for me to make mobile apps completely different from ASP.NET Applications?
3) Is it possible to use the same Azure SQL DB
for both ASP.NET WebApp as well as the Xamarin.Android
App?
Thanks in advance
Upvotes: 3
Views: 382
Reputation: 3274
The best way to do is by Web Services, you can follow this WCF tutorial.
Trying to answer your questions:
1) Why can't I use SqlConnecton classes inside Xamarin.Android's cs classes?
Mobile Apps are not designed for running common Database Engines like SQL Server, Oracle, etc. Because they consume a lot of resources and power. Imagine that you are connecting to any of these tools they would kill the battery in a couple of minutes/hours for sure. That's why if you really want to have an offline DB or something like that you have options like SQLite.
As a Xamarin developer if you must have the DB, I recommend you this package for SQLite:
2) Is there a different approach for me to make mobile apps completely different from ASP.NET Applications?
Yes and no, what do I mean, you can use WCF (Windows Communication Foundation), Generic Handlers, etc. The main idea is that you need to create a Web Service that is a "link" that you can access from your Apps for example:
The Wikipedia API:
This example returns you a JSON of Stack Overflow and you can do the same with any online DB you return the table/view that you want in JSON/XML format, you transform the answer into C# classes with a tool like Json2CSharp
Finally, you can deserialize the JSON to C# with a library like JSON.NET
3) Is it possible to use the same Azure SQL DB for both ASP.NET WebApp as well as the Xamarin.Android App?
Yes, you can. Many web sites and applications share the same DB, you just need to consider the Web Service approach in order to connect, update, delete, etc. From your app.
Upvotes: 2