简体   繁体   English

Visual Studio 2015 apache 科尔多瓦

[英]Visual Studio 2015 apache cordova

I have an app that uses WebSQL transactions to create a table, insert data, and retrieve information from a database.我有一个应用程序,它使用 WebSQL 事务来创建表、插入数据和从数据库中检索信息。

The app works fine on the Ripple Nexus (Galaxy) but not on the device (Galaxy Note 5) nor the emulator.该应用程序在 Ripple Nexus (Galaxy) 上运行良好,但不适用于设备 (Galaxy Note 5) 和模拟器。 The UI is there: text boxes, labels, buttons, etc. However, according to my notice, the operations on the database are not performed. UI在那里:文本框,标签,按钮等。但是,根据我的注意,不执行对数据库的操作。

What can I do?我能做什么?

There are not enough details here to tell what is going on and no code samples.这里没有足够的细节来说明发生了什么,也没有代码示例。 Note that ripple is using http and your app on the device is probably using a non http:// calling location.请注意,ripple 使用的是 http,而您设备上的应用程序可能使用的是非 http:// 调用位置。 Another possible issue is that on your machine there is web connectivity to a local http endpoint and on the device the end point would not be available unless it is public on the internet / available to the device.另一个可能的问题是,在您的机器上有到本地 http 端点的 Web 连接,而在设备上,端点将不可用,除非它在互联网上公开/可供设备使用。

Here is sample of my code, open database and populate data tables:这是我的代码示例,打开数据库并填充数据表:

document.addEventListener('deviceready', onDeviceReady.bind(this), false);
var db = openDatabase('DUTIESDB', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
    tx.executeSql("DROP TABLE DUTIES", []);
    tx.executeSql("DROP TABLE SDUTIES", []);
    tx.executeSql('CREATE TABLE IF NOT EXISTS DUTIES (id, name, date, time, course, room)');
    tx.executeSql('CREATE TABLE IF NOT EXISTS SDUTIES (id, name, date, time, course, room, invg)');
});

PupulateSupTable();

function PopulateSupTable() {
    var xmlhttp = new XMLHttpRequest();
    var url = "/scripts/SupDuties.txt";

    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            var myArr = JSON.parse(xmlhttp.responseText);
            db.transaction(
                function (tx) {
                    var k, sql = 'INSERT INTO SDUTIES (id, name, date, time, course, room, invg) VALUES (?,?,?,?,?,?,?)';
                    for (k = 0; k < myArr.length; k++) {
                        tx.executeSql(sql, [myArr[k].ID, myArr[k].Name, myArr[k].Date, myArr[k].Time, myArr[k].Course, myArr[k].Room, myArr[k].Invigilator]);
                    }
                }
            );
        }
    };
    xmlhttp.open("GET", url, true);
    xmlhttp.send();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM