1 | /****************************************************************************
|
---|
2 | ** $Id: main.cpp 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
3 | **
|
---|
4 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
5 | **
|
---|
6 | ** This file is part of an example program for Qt. This example
|
---|
7 | ** program may be used, distributed and modified without limitation.
|
---|
8 | **
|
---|
9 | *****************************************************************************/
|
---|
10 |
|
---|
11 | #include <qapplication.h>
|
---|
12 | #include <qsqldatabase.h>
|
---|
13 | #include <qsqlquery.h>
|
---|
14 | #include "../connection.h"
|
---|
15 |
|
---|
16 | bool createConnections();
|
---|
17 |
|
---|
18 |
|
---|
19 | int main( int argc, char *argv[] )
|
---|
20 | {
|
---|
21 | QApplication app( argc, argv, FALSE );
|
---|
22 |
|
---|
23 | int rows = 0;
|
---|
24 |
|
---|
25 | if ( createConnections() ) {
|
---|
26 | QSqlQuery query( "INSERT INTO staff ( id, forename, surname, salary ) "
|
---|
27 | "VALUES ( 1155, 'Ginger', 'Davis', 50000 )" );
|
---|
28 | if ( query.isActive() ) rows += query.numRowsAffected() ;
|
---|
29 |
|
---|
30 | query.exec( "UPDATE staff SET salary=60000 WHERE id=1155" );
|
---|
31 | if ( query.isActive() ) rows += query.numRowsAffected() ;
|
---|
32 |
|
---|
33 | query.exec( "DELETE FROM staff WHERE id=1155" );
|
---|
34 | if ( query.isActive() ) rows += query.numRowsAffected() ;
|
---|
35 | }
|
---|
36 |
|
---|
37 | return ( rows == 3 ) ? 0 : 1;
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|