如何从Android的数据发送到SQL Server 2008? [英] How to send data from android to SQL Server 2008?
问题描述
我已创建了一个网站和Android的applcation,我已经使用的支持与SQL Server 2008。 我已经使用Web服务显示来自服务器的数据,Android的应用程序,我已经使用JSON和KSOAP库,这是工作的罚款。我可以显示来自服务器的数据到Android。但现在我想从Android应用程序将数据存储到SQL Server 2008。因此,任何人请告诉我一步或如何我能做到这一点。请大家帮帮忙。
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.
推荐答案
您可以通过Web服务连接到SQL Server数据库。
You can connect to SQL Server database through webservice.
下面是示例code调用Web服务。
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();}
这篇关于如何从Android的数据发送到SQL Server 2008?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!