Line | |
---|
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 <qsqlcursor.h>
|
---|
14 | #include "../connection.h"
|
---|
15 |
|
---|
16 | int main( int argc, char *argv[] )
|
---|
17 | {
|
---|
18 | QApplication app( argc, argv, FALSE );
|
---|
19 |
|
---|
20 | if ( createConnections() ) {
|
---|
21 | int count = 0;
|
---|
22 | QSqlCursor cur( "prices" );
|
---|
23 | QStringList names = QStringList() <<
|
---|
24 | "Screwdriver" << "Hammer" << "Wrench" << "Saw";
|
---|
25 | int id = 20;
|
---|
26 | for ( QStringList::Iterator name = names.begin();
|
---|
27 | name != names.end(); ++name ) {
|
---|
28 | QSqlRecord *buffer = cur.primeInsert();
|
---|
29 | buffer->setValue( "id", id );
|
---|
30 | buffer->setValue( "name", *name );
|
---|
31 | buffer->setValue( "price", 100.0 + (double)id );
|
---|
32 | count += cur.insert();
|
---|
33 | id++;
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | return 0;
|
---|
38 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.