Solved

deleterow();

Posted on 2013-12-29
1
332 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
ID: 39745619
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
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…

777 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