Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未找到Tianium-JavaScript-SQLite表?_Javascript_Sqlite_Titanium Mobile - Fatal编程技术网

未找到Tianium-JavaScript-SQLite表?

未找到Tianium-JavaScript-SQLite表?,javascript,sqlite,titanium-mobile,Javascript,Sqlite,Titanium Mobile,谢谢你抽出时间 学校一直要求我与当地的数据库合作,尽管我要求了很多帮助,但什么都没有得到。所以,我试图创建一个超级简单的应用程序,它有一个数据库,并在此基础上围绕它构建一个应用程序。我使用了来自的教程代码,但似乎每次都会出现相同的错误 nativeReason = "Error Domain=com.plausiblelabs.pldatabase Code=3 \"An error occured parsing the provided SQL statement.\" UserInfo=0

谢谢你抽出时间

学校一直要求我与当地的数据库合作,尽管我要求了很多帮助,但什么都没有得到。所以,我试图创建一个超级简单的应用程序,它有一个数据库,并在此基础上围绕它构建一个应用程序。我使用了来自的教程代码,但似乎每次都会出现相同的错误

nativeReason = "Error Domain=com.plausiblelabs.pldatabase Code=3 \"An error occured parsing the provided SQL statement.\" UserInfo=0xcf52be0 {com.plausiblelabs.pldatabase.error.vendor.code=1, NSLocalizedDescription=An error occured parsing the provided SQL statement., com.plausiblelabs.pldatabase.error.query.string=INSERT INTO tablename (id, company) VALUES(?,?), com.plausiblelabs.pldatabase.error.vendor.string=no such table: tablename}";
我不明白为什么,因为我完全按照网站上说的去做。我以前创建的几乎每个应用程序生成的表都有这个问题。我将把我添加的代码放在这里,但是对于任何关于错误的建议都将不胜感激

Titanium.UI.setBackgroundColor('#000');

var win = Ti.UI.createWindow({backgroundColor: "#fff"});

var db = Titanium.Database.open('myDatabase');

db.execute('CREATE TABLE IF NOT EXISTS tablename (id INTEGER PRIMARY KEY, company TEXT)');

var companyfield = Titanium.UI.createTextField({
hintText:'Name',
height:35,
top:200,
left:30,
width:250,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});

win.add(companyfield);

var save = Titanium.UI.createButton({
title:'Save Info',
top:350,
left:30,
height:30,
width:250
});
win.add(save);

// ----- Create an event listener for the tableView ----- //
save.addEventListener('click', function(e) {

//this variable holds whatever was typed in the textbox
var passaction = companyfield.value;

//this opens the database
var db = Titanium.Database.open('myinfodb');

//this puts the data into the field
db.execute('INSERT INTO tablename (id, company) VALUES(?,?)', 1, passaction);
});

win.open();
您的错误是:

在您提供的代码中:

var db = Titanium.Database.open('myDatabase'); //----> DB NAME = myDatabase

db.execute('CREATE TABLE IF NOT EXISTS tablename (id INTEGER PRIMARY KEY, company TEXT)');
后来在代码中,您编写了:

var db = Titanium.Database.open('myinfodb'); //----> DB NAME = myinfodb

db.execute('INSERT INTO tablename (id, company) VALUES(?,?)', 1, passaction);
因此,问题很简单,您需要创建两个不同的数据库

因此DB NAME=myDatabase包含table=tablename,但DB NAME=myinfodb不包含table=tablename。