summaryrefslogtreecommitdiffstats
path: root/examples/declarative/sqllocalstorage/hello.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/sqllocalstorage/hello.qml')
-rw-r--r--examples/declarative/sqllocalstorage/hello.qml31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml
new file mode 100644
index 0000000..8b021b7
--- /dev/null
+++ b/examples/declarative/sqllocalstorage/hello.qml
@@ -0,0 +1,31 @@
+import Qt 4.7
+
+Text {
+ text: "?"
+
+ function findGreetings() {
+ var db = openDatabaseSync("QDeclarativeExampleDB", "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)');
+
+ // Add (another) greeting row
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+
+ // Show all added greetings
+ 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
+ }
+ )
+ }
+
+ Component.onCompleted: findGreetings()
+}
+