summaryrefslogtreecommitdiffstats
path: root/experimental/tqtinterface/qt4/tools/designer/examples/book/connection.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:17:53 -0500
commit37e3f157c7d76f13de807fa66e36df209e1005fb (patch)
tree7a4f131b2ee065337dac341bff34515310efba4f /experimental/tqtinterface/qt4/tools/designer/examples/book/connection.cpp
parent16630c3eff313238fa8412275555285c9195981b (diff)
downloadtde-37e3f157c7d76f13de807fa66e36df209e1005fb.tar.gz
tde-37e3f157c7d76f13de807fa66e36df209e1005fb.zip
Added TQt4 HEAD
Diffstat (limited to 'experimental/tqtinterface/qt4/tools/designer/examples/book/connection.cpp')
-rw-r--r--experimental/tqtinterface/qt4/tools/designer/examples/book/connection.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/experimental/tqtinterface/qt4/tools/designer/examples/book/connection.cpp b/experimental/tqtinterface/qt4/tools/designer/examples/book/connection.cpp
new file mode 100644
index 000000000..190d4fcc9
--- /dev/null
+++ b/experimental/tqtinterface/qt4/tools/designer/examples/book/connection.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+#include <tqsqldatabase.h>
+#include "connection.h"
+
+bool createConnections()
+{
+ // create the default database connection
+ TQSqlDatabase *defaultDB = TQSqlDatabase::addDatabase( DB_BOOKS_DRIVER );
+ defaultDB->setDatabaseName( DB_BOOKS );
+ defaultDB->setUserName( DB_BOOKS_USER );
+ defaultDB->setPassword( DB_BOOKS_PASSWD );
+ defaultDB->setHostName( DB_BOOKS_HOST );
+ if ( ! defaultDB->open() ) {
+ qWarning( "Failed to open books database: " +
+ defaultDB->lastError().driverText() );
+ qWarning( defaultDB->lastError().databaseText() );
+ return FALSE;
+ }
+
+ TQSqlQuery q(TQString(), defaultDB);
+ q.exec("CREATE TABLE author ( id integer primary key, "
+ "forename varchar(40), surname varchar(40) )");
+ q.exec("CREATE TABLE book ( id integer primary key, "
+ "title varchar(40), price numeric(10,2), authorid integer, notes varchar(255) )");
+
+ q.exec("CREATE TABLE sequence ( tablename varchar(10), sequence numeric)");
+
+ q.exec("INSERT INTO author VALUES ( 0, 'Philip K', 'Dick' )");
+ q.exec("INSERT INTO author VALUES ( 1, 'Robert', 'Heinlein' )");
+ q.exec("INSERT INTO author VALUES ( 2, 'Sarah', 'Paretsky' )");
+
+ q.exec("INSERT INTO book VALUES (0, 'The Man Who Japed', 6.99, 0, 'A good book' )");
+ q.exec("INSERT INTO book VALUES (1, 'The Man in the High Castle', 9.99, 0, 'Worth reading' )");
+ q.exec("INSERT INTO book VALUES ( 2, 'The Number of the Beast', 8.99, 1, 'Get this!' )");
+ q.exec("INSERT INTO book VALUES ( 3, 'Indemnity Only', 9.99, 2, 'Cool' )");
+ q.exec("INSERT INTO book VALUES ( 4, 'Burn Marks', 9.99, 2, 'Need to make notes' )");
+ q.exec("INSERT INTO book VALUES ( 5, 'Deadlock', 9.99, 2, 'Hmmm..' )");
+
+ q.exec("INSERT INTO sequence VALUES ( 'author', 2 )");
+ q.exec("INSERT INTO sequence VALUES ( 'book', 5 )");
+
+ return TRUE;
+}
+
+