summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-20 00:33:54 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-20 00:33:54 (GMT)
commitf56f8418ece38e74cdf2830dcd7f9660631295b1 (patch)
treed1f946bd1ca99c401d34cf130ec4ec9e115dfa7f /examples/declarative
parent074bcbc746ab3f8669634ff00af0250b592baa48 (diff)
downloadQt-f56f8418ece38e74cdf2830dcd7f9660631295b1.zip
Qt-f56f8418ece38e74cdf2830dcd7f9660631295b1.tar.gz
Qt-f56f8418ece38e74cdf2830dcd7f9660631295b1.tar.bz2
asynchronous
Diffstat (limited to 'examples/declarative')
-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()
}
+