summaryrefslogtreecommitdiffstats
path: root/examples/declarative/sql/hello.qml
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-18 03:02:52 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-18 03:02:52 (GMT)
commit178d8c9cb87c5578e5175b5a405d470919644c4d (patch)
treee04fb8e083b266032ac5c6da37637ccff862a9fd /examples/declarative/sql/hello.qml
parent6329879b47afad504eab2e629d15404bf7224cfb (diff)
downloadQt-178d8c9cb87c5578e5175b5a405d470919644c4d.zip
Qt-178d8c9cb87c5578e5175b5a405d470919644c4d.tar.gz
Qt-178d8c9cb87c5578e5175b5a405d470919644c4d.tar.bz2
Update examples for new SQL API.
Diffstat (limited to 'examples/declarative/sql/hello.qml')
-rw-r--r--examples/declarative/sql/hello.qml29
1 files changed, 9 insertions, 20 deletions
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
index dc3ca35..96e0675 100644
--- a/examples/declarative/sql/hello.qml
+++ b/examples/declarative/sql/hello.qml
@@ -3,35 +3,24 @@ import Qt 4.6
Text {
Script {
function findGreetings() {
- var db = openDatabase("QmlExampleDB", "1.0", "The Example QML SQL!", 1000000);
+ var db = openDatabaseSync("QmlExampleDB", "1.0", "The Example QML SQL!", 1000000);
db.transaction(
function(tx) {
// Create the database if it doesn't already exist
- tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)', []);
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
// Add (another) greeting row
tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
// Show all added greetings
- 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() {
- print("ERROR in transaction");
- },
- function() {
- print("Transaction successful");
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+
+ 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
}
)
}