Created
June 28, 2010 15:59
-
-
Save bmadigan/456006 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
var adp = Titanium.API.Application.getDataPath(); | |
var dbpath = adp+"\\"+"sampledb.db"; | |
var db = Titanium.Database.openFile(dbpath); | |
//var db = Titanium.Database.open('recruitment'); // this doesn't work either | |
} | |
catch (e) { | |
alert(e); // seems to connect as this doesn't come up | |
} | |
// select | |
var result = db.execute('SELECT firstname, lastname FROM users'); | |
// Create an array | |
var rs = []; | |
var j = 0; | |
try { | |
while (result.isValidRow()) | |
{ | |
rs[j][firstname] = result.fieldByName('firstname'); | |
rs[j][lastname] = result.fieldByName('lastname'); | |
j++; | |
result.next(); | |
} | |
} catch(e) { | |
alert('Note: You have not entered any valid Users yet.'); // THIS IS ALWAYS CALLED | |
} | |
// close result set | |
result.close(); | |
db.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment