How to use web service to connect SQL database created in .NET to Android
I am new to the .NET Framework. I am using Visual Studio 2008 in which I need to create a simple SQL database with say 2 columns "name" and "address" . After that I need to create a web service (REST or SOAP) that will expose my database . Also I need to develop an Android application u开发者_StackOverflowsing which I can insert ,delete , update and view the contents of my database at any point of time via the webservice using respective buttons . As I would be developing it on my machine itself , I would use localhost and not any remote server.
can anyone suggest me how should i go about doing this?
Your task is not actually simple and you might need to do some learning here. The question is very broad and this is why the answer is a bit abstract.
As I see it you may need
Database
Create a database with a table that satisfies your task. You can use ORM frameworks for simplicity (if you know how to use them) or can write it manually in SQL.
Service
It's better to use WCF REST here as you need it to work with Android. Data shall be returned in XML, JSON or ATOM. Design an interface with the specified action (CRUD). You will be able to test it in your browser or via traffic sniffer (like Fiddler). Your service will need some infrastructure plumbing code to access db.
See this blog, msdn article or just google.
Android
You need to learn how to consume REST service from Android (which, I assume, will use Java). Once the service is consumed, you just wire the remote method calls to the button clicks, and assign the return values to the Android GUI.
精彩评论