Solved

deleterow();

Posted on 2013-12-29
1
307 Views
Last Modified: 2013-12-31
I'm trying to loop through the sqlite database to transmit the data to the server ... once the data is transmitted successfully and the server returns "1" I want it to delete the row just transmitted (.deleterow) then next transmit the next row (.next)... but the way I am doing it isn't working

if(jObject.Result == 1)
{ getGroundData.deleteRow();
 getGroundData.next();

Open in new window



var Groundy = function(){
var db = Ti.Database.open('TennisApp');
var getGroundData = db.execute('SELECT user, MatchUID,Ossys, UserID, SetPrKey, Game, Point, Stroke, XCor, YCor FROM GroundStrokeData');
while (getGroundData.isValidRow())
{
     var user = getGroundData.fieldByName('UserID');
     var UserID = getGroundData.fieldByName('UserID');
     var MatchUID = getGroundData.fieldByName('MatchUID'); 
     var Ossys = getGroundData.fieldByName('Ossys');
     var SetPrKey = getGroundData.fieldByName('SetPrKey'); 
     var Game = getGroundData.fieldByName('Game');
     var Point = getGroundData.fieldByName('Point');  
     var Stroke = getGroundData.fieldByName('Stroke'); 
 
     var XCor = getGroundData.fieldByName('XCor');
     var YCor = getGroundData.fieldByName('YCor');
  GroundDtrokeTransmit(user, MatchUID, Ossys, UserID, SetPrKey, Game,  Point, Stroke, XCor, YCor);
 
}
db.execute('DELETE FROM GroundStrokeData');
getGroundData.close();
db.close();
 
};
 
var GroundDtrokeTransmit = function(user, MatchUID, Ossys,  UserID, SetPrKey){ 
var xhr=Titanium.Network.createHTTPClient();    
 xhr.onerror = function(e){ 
 Ti.API.error('groundy Bad Sever =>'+e.error);
};

Open in new window

0
Comment
Question by:dolamitejenkins
1 Comment
 
LVL 38

Accepted Solution

by:
Aaron Tomosky earned 500 total points
Comment Utility
I'm no js expert, but usually you just update a column in the row to show the record has been sent. E.g make a column called issent with a default of 0 and set it to 1 instead of trying to delete the row. Then at the end you can delete where issent=1 if you want, or just leave them for clean up later and add where issent !=1 to your input query.

I don't know if the row is locked or what your current problem is, but this may fix it. If it doesn't it's still a good idea.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now