1

I have created one web site and android applcation and I have used backed as SQL Server 2008. I have used web services to display data from server to android application for that i have used JSON and ksoap library and it is working fine. I can display data from server to android. But now i want to store data from android application to SQL Server 2008. So anyone please tell me the step or how i can do that. Please help.

asked Jan 8, 2013 at 10:01
1
  • 1
    "android post request" type that on Google.com Commented Jan 8, 2013 at 10:03

2 Answers 2

1

You can connect to SQL Server database through webservice.

Here is the sample code to call the webservice.

String url = "your_webservice_URL";
 try 
 {
 HttpPost loginHttpPost = new HttpPost(url); 
 HttpContext localContext = new BasicHttpContext(); 
 MultipartEntity multipartContent = new MultipartEntity();
 multipartContent.addPart("parameter1", new StringBody(value1));
 multipartContent.addPart("parameter2", new StringBody(value2));
 loginHttpPost.setEntity(multipartContent);
 HttpClient objHttpClient = new DefaultHttpClient();
 HttpResponse response = objHttpClient.execute(loginHttpPost,localContext);
 } 
 catch (IOException e) {
 e.printStackTrace();}
answered Jan 8, 2013 at 10:04
3
  • ok...but can you tell me how i can write asp.net web service to insert data?? Commented Jan 8, 2013 at 10:09
  • actually i have created the web service for display data by calling the stored procedure. but i dont know how to insert data from web service. Commented Jan 8, 2013 at 10:13
  • stackoverflow.com/questions/13379936/… Commented Jan 8, 2013 at 10:18
0

Here is the example source code to Connect Android to SQL sever via WCF using JSON

Example :

1. Connecting Android to SQL Server

2. Get Data using XML

3. Get Data using JSON

- Inserting Data into database using WCF Service

answered Jan 8, 2013 at 10:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.