mysql - Attaching an android form to asp.net -
i creating android application have form user needs fill up. want send values inserted asp.net page catches data , saves database attached page , after value gets inserted database database sends response android application. 1 or 0 send feedback 1 successful data entry 0 failure.
can done if how?? please , thank you.
this android code
public void postdata() { // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://www.yoursite.com/myexample.aspx"); try { // add data list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("empid", "12345")); //keep adding namevaluepairs.add(new basicnamevaluepair("secondvariable", "12345")); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); httpentity entity = httpresponse.getentity(); inputstream = entity.getcontent(); //string response server string whatigotresponse= convertstreamtostring(is); } catch (clientprotocolexception e) { // todo auto-generated catch block } catch (ioexception e) { // todo auto-generated catch block } } private static string convertstreamtostring(inputstream is) { bufferedreader reader = new bufferedreader(new inputstreamreader(is)); stringbuilder sb = new stringbuilder(); string line = null; try { while ((line = reader.readline()) != null) { sb.append((line + "\n")); } } catch (ioexception e) { e.printstacktrace(); } { try { is.close(); } catch (ioexception e) { e.printstacktrace(); } } return sb.tostring(); }
in aspx page, can retrive data with
//all namevaluepairs have send string empid = request.form["empid"]; //now use basic sql connection values insert sql........ // after sql query can use response.write("something something");
Comments
Post a Comment