summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/sql/hello.qml46
1 files changed, 27 insertions, 19 deletions
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
index db568a9..20ea611 100644
--- a/examples/declarative/sql/hello.qml
+++ b/examples/declarative/sql/hello.qml
@@ -2,28 +2,36 @@ import Qt 4.6
Text {
Script {
- function allGreetings()
- {
+ function findGreetings() {
var db = openDatabase("QmlExampleDB", "", "The Example QML SQL!", 1000000);
- var r = ""
- db.transaction(function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)', []);
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
- tx.executeSql('SELECT * FROM Greeting', [],
- function(tx, rs) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)', []);
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('SELECT * FROM Greeting', [],
+ function(tx, rs) {
+ var r = ""
+ for(var i = 0; i < rs.rows.length; i++) {
+ r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
+ }
+ text = r
+ },
+ function(tx, error) {
+ print("ERROR:", error.message)
}
- },
- function(tx, error) {
- print("ERROR:", error.message)
- }
- );
- })
-
- return r
+ );
+ },
+ function() {
+ print("ERROR in transaction");
+ },
+ function() {
+ print("Transaction successful");
+ }
+ )
}
}
- text: allGreetings()
+ text: "?"
+ Component.onCompleted: findGreetings()
}
+