我想从eclipse将数据保存到sql server是否有任何解决方案?

时间:2012-11-30 04:39:22

标签: android asp.net web-services

我想从eclips将数据保存到sql server是否有任何解决方案? 是否可以使用Web服务或json .. 我已经制作了一个asp.net网站,并为方法制作了网络服务......并且通过json将数据导入eclips ......所以现在如何从elips获取导管数据?

3 个答案:

答案 0 :(得分:0)

我使用belove代码从android中获取数据来自android中的web webservice试试这个

 public static String SOAP_NAMESPACE = "http://myweb.com/";
public static String SOAP_METHOD_GetQuestionAnswer = "GetQuestionAnswer";

// GetQuestionAnswer Method
public static String GetQuestionAnswer(String GameIDValue, String QuestionIDValue) {
    String responce = null; 

    SoapObject request = new SoapObject(SOAP_NAMESPACE, SOAP_METHOD_GetQuestionAnswer);

    PropertyInfo GameID = new PropertyInfo();
    PropertyInfo QuestionID = new PropertyInfo();

    GameID.setName("gameid");
    GameID.setValue(GameIDValue);

    QuestionID.setName("queid");
    QuestionID.setValue(QuestionIDValue);

    request.addProperty(GameID);
    request.addProperty(QuestionID);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE aht = new HttpTransportSE(SOAP_URL);
    try {
        aht.call(SOAP_ACTION_GetQuestionAnswer, envelope);
        SoapPrimitive LoginResult;
        LoginResult = (SoapPrimitive)envelope.getResponse();
        System.out.println("=================GetQuestion Results: "+LoginResult);
        System.out.println(LoginResult.toString());
        responce = LoginResult.toString();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return responce;
}

答案 1 :(得分:0)

在Android中,您可以在JSON object中创建POSTasp web service,最终将数据发送到remote sql database

JSONObject obj = new JSONObject();
obj.put("val1",val1);
obj.put("val2",val2);
obj.put("val3",val3);

答案 2 :(得分:0)

@shivanipatel

首先从服务器端你想拥有或创建任何网络服务,以便从android接收你的请求并回复该请求.. ///

之后你想使用
使用NameValuePair来发布数据。

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>;
nameValuePairs.add(new BasicNameValuePair("name", Name));
nameValuePairs.add(new BasicNameValuePair("number", Number));

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

HttpResponse response = httpclient.execute(httppost);

它会帮助你亲爱的

- Jatin Patel