Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var db;
- document.addEventListener("deviceready", onDeviceReady, false);
- // Cordova is ready
- function onDeviceReady() {
- alert ("device ready");
- //This Enable/Disable the Screen Orientation
- intel.xdk.device.setAutoRotate(true);
- // This will create the Database.
- //db = window.sqlitePlugin.openDatabase("Database", "1.0", "Demo", -1);
- db = sqlitePlugin.openDatabase(
- // options
- {
- name: "MyDatabase.db",
- location: 0 // for iOS (0=Documents (default, visible in iTunes, backed up by iCloud), 1=Library (not visible in iTunes, backed up by iCloud, 2=Library/LocalDatabase (not visible in iTunes, not backed up by iCloud))
- },
- // success callback
- function (msg) {
- alert("success Creating DB: " + msg);
- },
- // error callback
- function (msg) {
- alert("error on Create DB: " + msg);
- }
- );
- createDB();
- }
- function createDB(){
- db.transaction(function(tx) {
- //tx.executeSql('DROP TABLE IF EXISTS test_table');
- tx.executeSql('CREATE TABLE IF NOT EXISTS test_table(UserID integer, UserName text)');
- alert("table created");
- }, function(e) {
- alert("ERROR: " + e.message);
- });
- }
- //Call this function to insert:
- function InsertUserLog(pUserID, pUserName, pTechID, pBranchID, pBranchCode, pDeviceID, pPassword, pLogInDate, pTruckID){
- db.transaction(function(tx) {
- tx.executeSql("INSERT INTO TblUserLog (UserID, UserName) VALUES (?,?)", [pUserID, pUserName], function(tx, res) {
- //alert("insertId: " + res.insertId + " -- probably 1");
- //alert("rowsAffected: " + res.rowsAffected + " -- should be 1");
- updateProgressBar(50);
- }, function(e) {
- alert("ERROR: " + e.message);
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement