-
Unable to open Database
Hi sorry to bother you guys but I just started playing around with QML and JavaScript recently and facing a probably simple to solve issue...but one that is driving me mad :mad:
I read all tutorials on this and already dived into the source of the QML competition apps, but regardless what I am doing and what example I plainly copy, I am not able to open/store/retrieve data from a SQLITE database at all and always get this error message:
[code]QSqlQuery::prepare: database not open[/code]
Here is some very simple sample code that reproduces the error:
[CODE] Rectangle {
width: 360
height: 360
id: screen
color: "blue"
Text {
id: textDisplay
anchors.centerIn: parent
color: "red"
text: "?"
}
Component.onCompleted: {
var db = openDatabaseSync("MyAppName", "1.0", "StorageDatabase", 100000);
db.transaction(function(tx){tx.executeSql('CREATE TABLE IF NOT EXISTS test(id VARCHAR PRIMARY KEY NOT NULL, version INTEGER, serialized TEXT)');});
db.transaction(function(tx){tx.executeSql('INSERT INTO tesst VALUES (?,?,?)', ['1234', 1, 'test test test']);});
var rs = db.transaction(function(tx){tx.executeSql('SELECT * FROM test');});
}
}[/CODE]
I am using the Nokia QT SDK downloaded from nokia.com:
[LIST][*]QT Creator 2.2.1 (revision 74d015d2a9 ?)[*]QT 4.7.4 64bit[*]Ubuntu 11.04 64bit[*]libqt4-sql-sqlite installed[/LIST]
Hope someone can help me here, because I am totally stuck...thanks.