summaryrefslogtreecommitdiffstats
path: root/examples/declarative/sql
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/sql')
-rw-r--r--examples/declarative/sql/hello.qml30
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
new file mode 100644
index 0000000..fb6d21c
--- /dev/null
+++ b/examples/declarative/sql/hello.qml
@@ -0,0 +1,30 @@
+import Qt 4.6
+
+Text {
+ Script {
+ function test()
+ {
+ var db = openDatabase("QmlExampleDB", "", "The Example QML SQL!", 1000000);
+ print(db)
+ 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[i][0] + ", " + rs.rows[i][1] + "\n"
+ }
+ },
+ function(tx, error) {
+ print("ERROR:", error.message)
+ }
+ );
+ })
+
+ return r
+ }
+ }
+ text: test()
+}