1. Kumar Krishnan's Avatar
    Hi i have a .Net webservice calling through android mobile using ksoap2 and try to upload the records to server from android sqlite, everything fine and records were uploaded.When i clicked the upload button in the mobile 3 records are inserted in the server stock table and column MobileRowId records like 1,1,1 respectively (but i need 1,2,3). Because mobile sqlite having only 3 records.Next time clicked the upload button again 3 records are inserted in stock table and column MobileRowId like 2,2,3 respectively (but i need 1,2,3).
    Here my code as below
    Cursor cur = db.query("tblstk", null, null, null, null, null, null);
    int iCount =cur.getCount();
    if (iCount > 0)
    {
    while(cur.moveToNext()) {
    int SalesPersonID = Integer.parseInt(cur.getString(0));
    int CustomerGroupID = Integer.parseInt(cur.getString(1));
    String CustomerID = cur.getString(2);
    String pDate = cur.getString(3);
    int Balancestock = Integer.parseInt(cur.getString(4));
    String ItemDescription = cur.getString(5);
    String CategoryCode = cur.getString(6);
    String ItemCode =cur.getString(7);
    int Localareacode = Integer.parseInt(cur.getString(8));
    int Cellid = Integer.parseInt(cur.getString(9));
    String TakeDateTime =cur.getString(10);
    int intRowID = Integer.parseInt(cur.getString(11));
    // int intStatusCode
    PropertyInfo pi=new PropertyInfo();
    pi.setName("SalesPersonID");
    pi.setValue(SalesPersonID);
    pi.setType(Integer.class);
    request.addProperty(pi);
    PropertyInfo InfoDate=new PropertyInfo();
    InfoDate.setName("Date");
    InfoDate.setValue(pDate);
    InfoDate.setType(String.class);
    request.addProperty(InfoDate);

    PropertyInfo InfoCustomerID=new PropertyInfo();
    InfoCustomerID.setName("CustomerID");
    InfoCustomerID.setValue(CustomerID);
    InfoCustomerID.setType(String.class);
    request.addProperty(InfoCustomerID);

    PropertyInfo InfoGroup=new PropertyInfo();
    InfoGroup.setName("CustomerGroupID");
    InfoGroup.setValue(CustomerGroupID);
    InfoGroup.setType(Integer.class);
    request.addProperty(InfoGroup);

    PropertyInfo InfoStock=new PropertyInfo();
    InfoStock.setName("Stock");
    InfoStock.setValue(Balancestock);
    InfoStock.setType(Integer.class);
    request.addProperty(InfoStock);

    PropertyInfo Infodescription=new PropertyInfo();
    Infodescription.setName("ItemDescription");
    Infodescription.setValue(ItemDescription);
    Infodescription.setType(String.class);
    request.addProperty(Infodescription);

    PropertyInfo Infocategorycode=new PropertyInfo();
    Infocategorycode.setName("CategoryID");
    Infocategorycode.setValue(CategoryCode);
    Infocategorycode.setType(String.class);
    request.addProperty(Infocategorycode);

    PropertyInfo Infoitemcode=new PropertyInfo();
    Infoitemcode.setName("ItemCode");
    Infoitemcode.setValue(ItemCode);
    Infoitemcode.setType(String.class);
    request.addProperty(Infoitemcode);

    PropertyInfo Infoloacalareacode=new PropertyInfo();
    Infoloacalareacode.setName("LocalAreaCode");
    Infoloacalareacode.setValue(Localareacode);
    Infoloacalareacode.setType(Integer.class);
    request.addProperty(Infoloacalareacode);

    PropertyInfo Infocellid=new PropertyInfo();
    Infocellid.setName("intCellID");
    Infocellid.setValue(Cellid);
    Infocellid.setType(Integer.class);
    request.addProperty(Infocellid);

    PropertyInfo Infotakedatetime=new PropertyInfo();
    Infotakedatetime.setName("takeDate");
    Infotakedatetime.setValue(TakeDateTime);
    Infotakedatetime.setType(String.class);
    request.addProperty(Infotakedatetime);

    PropertyInfo Inforowid=new PropertyInfo();
    Inforowid.setName("MobileStockRowID");
    Inforowid.setValue(intRowID);
    Inforowid.setType(Integer.class);
    request.addProperty(Inforowid);

    SoapSerializationEnvelope senvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    senvelope.setOutputSoapObject(request);
    senvelope.dotNet = true;
    try {
    strSalespersonID = global.getId();
    HttpTransportSE HttpTransport = new HttpTransportSE(URL,TimeOut);
    HttpTransport.call(SOAP_ACTION, senvelope);
    String result =null;
    SoapPrimitive response =null;
    response = (SoapPrimitive)senvelope.getResponse();
    result = response.toString();
    if(result != null)
    {
    String TABLE= "tblstk";
    String KEY_NAME = "ID";
    int iRid = Integer.parseInt(result);
    db.delete(TABLE, KEY_NAME + "=" + iRid, null);
    Cursor curt = db.query("tblstk",null, null, null, null, null, null); int iCountt =curt.getCount();
    Toast.makeText(getApplicationContext(), "Stocks upload successfully",Toast.LENGTH_LONG).show();
    }
    else
    { Toast.makeText(getApplicationContext(), "Server not return value",Toast.LENGTH_LONG).show();
    }

    } catch (Exception e)
    {
    Toast.makeText(getApplicationContext(), e.toString(),Toast.LENGTH_LONG).show();
    strSalespersonID = global.getId();
    errorMessage = e.toString();
    errorlog.LogError("1", "UploadActivity", "InsertStocks", errorMessage.toString(), "", strSalespersonID);

    }

    }
    }
    else
    {
    Toast.makeText(getApplicationContext(), "Records not found",Toast.LENGTH_LONG).show();
    }
    cur.close();
    when I click the upload button for the first time I debug the code, the response returns the same MobileRowId as 1 from the server until upload of 3 records. The 3 records of MobileRowId was 1,2,3 in sqlite.

    when I click the upload button for the Second time
    the response returns the same MobileRowId as 2,2 and 3 from the server until upload of 3 records. The 3 records of MobileRowId was 1,2,3 in sqlite.

    I want inserted records in the server should be shows only 3 records but shows 6 records.
    The same service I was used in windows mobile 6.1 records inserted correctly and fine.
    But in the android I have problem.
    Whats wrong in my code could anybody solve my problem
    03-15-2015 03:09 AM
  2. Rukbat's Avatar
    If the RowID you're working on in the phone exists in the server's database, either UPDATE (rather than INSERT), assuming that the data has changed, or only INSERT if a SELECT on that RowID (on the server) returns 0 records if the data doesn't get changed. (Or read the server row and check to see if the data was changed and update or not, accordingly.)

    Inserting the same data 3 times will give you 3 identical records, assuming there are no fields that can't be duplicated.
    03-15-2015 02:50 PM
  3. Kumar Krishnan's Avatar
    Hi Rukbat calling same webservice from windows mobile 6.1 working fine, I seemed inserted data exit in the server, the RowID column allows duplicate value in server, my sql server stored procedure once insert the row in the server it returns the recently inserted RowID and send it to the mobile then delete the record based on RowID in the mobile, then i seemed the cursor record was deleted i mean RowID was "1"
    Loop iterate next record was upload to server from mobile the server return the ( previous RowID "1" ), actually here the RowID "2" was return to mobile then delete the record but RowID "1" returned. But working fine in the windows mobile 6.1. What happening in android i don't know can you plz help to me.

    First time hit the upload button in the mobile the inserted records in the server was:How do I upload sqlite data to server using ksoap?-untitled.png
    Second time hit the upload button in the mobile the inserted records in the server was
    03-16-2015 02:00 AM

Similar Threads

  1. Replies: 3
    Last Post: 03-22-2015, 03:52 PM
  2. Can I use my t-Mobile Galaxy S4 in the straight talk network?
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 03-18-2015, 05:50 PM
  3. Anyway to stop auto downloading Lollipop?
    By dj9928 in forum Samsung Galaxy S5
    Replies: 2
    Last Post: 03-15-2015, 02:52 PM
  4. Replies: 0
    Last Post: 03-15-2015, 02:45 AM
  5. Replies: 0
    Last Post: 03-15-2015, 12:02 AM
LINK TO POST COPIED TO CLIPBOARD