3

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

1 Answer 1

2

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:

SQLite-NET-PLC

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi, Thanks a lot and it definitely added more to my understanding. However it would be grateful if you could tell me what is the difference/correct approach among these two tutorials I found from keywords in your answer :-) <br/> 1) c-sharpcorner.com/article/… 2) youtube.com/watch?v=pwZoXkyK6Tk
Hi @IpeaSkyRock, I guess it depends on the approach and what kind of DB you're using, let's say that when you are talking about a Web Site, I imagine a "normal" DB I mean that you would have relationships, multiple tables, etc. Personally, this services from Azure to connect DBs in my experience are limited and are for simple or micro transactions if you want to do something bigger MS for sure would recommend you to use SQL Azure and not this services because they are not designed for huge projects. You have some questions for your: how huge is your project? Or how big would be your DB?
Hi @FedericoNavarrete Thanks a lot for you reply. So I tried to use these two Consuming a RESTful API and Microsoft Example for its back-end It doesn't seem to work though. Can you tell me whether or not this approach is correct? Thanks in advance :-)
Hi @IpeaSkyRock I'd do something like that, do you have any error? Have you checked if you have a valid JSON? jsonlint.com Maybe you have an error on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.