Can't connect to database to create table.") + "" + dbError.driverText() + "
" + dbError.databaseText() + i18n("
You can continue if the table exists already.
")) == KMessageBox::Cancel) {
+ return false;
+ }
+ }
+
+ // The database is created, now connect to the one specified by the user
+ dbase = TQSqlDatabase::addDatabase(driver, database );
+ dbase->setDatabaseName( database );
+ dbase->setUserName( username );
+ dbase->setPassword( password );
+ dbase->setHostName( hostname );
+ if(!dbase->open() || !dbase->isOpen()) {
+ KMessageBox::error( 0, i18n("KBarcode could not create the required database. Please create it manually.") + dbase->lastError().databaseText() );
+ TQSqlDatabase::removeDatabase( database );
+ return false;
+ }
+
+ TQSqlQuery query( NULL, dbase );
+
+ // barcode_basic
+ query.exec("DROP TABLE " TABLE_BASIC );
+ exec( &query, "CREATE TABLE " TABLE_BASIC " ("
+ " uid " + drivers[driver]->autoIncrement() + ","
+ " article_no varchar(50) DEFAULT NULL,"
+ " article_desc varchar(50) DEFAULT NULL,"
+ " barcode_no TEXT DEFAULT NULL,"
+ " encoding_type varchar(50) DEFAULT NULL,"
+ " field0 varchar(50) DEFAULT NULL,"
+ " field1 varchar(50) DEFAULT NULL,"
+ " field2 varchar(50) DEFAULT NULL,"
+ " field3 varchar(50) DEFAULT NULL,"
+ " field4 varchar(50) DEFAULT NULL,"
+ " field5 varchar(50) DEFAULT NULL,"
+ " field6 varchar(50) DEFAULT NULL,"
+ " field7 varchar(50) DEFAULT NULL,"
+ " field8 varchar(50) DEFAULT NULL,"
+ " field9 varchar(50) DEFAULT NULL,"
+ " PRIMARY KEY (uid)"
+ ");" );
+
+ // customer
+ query.exec("DROP TABLE " TABLE_CUSTOMER );
+ exec( &query, "CREATE TABLE " TABLE_CUSTOMER " ("
+ " uid " + drivers[driver]->autoIncrement() + " ,"
+ " customer_no varchar(20) DEFAULT NULL,"
+ " customer_name varchar(20) DEFAULT NULL,"
+ " PRIMARY KEY (uid)"
+ ");" );
+
+ // customer_text
+ query.exec("DROP TABLE " TABLE_CUSTOMER_TEXT );
+ exec( &query, "CREATE TABLE " TABLE_CUSTOMER_TEXT " ("
+ " uid " + drivers[driver]->autoIncrement() + ","
+ " customer_no varchar(20) DEFAULT NULL,"
+ " encoding_type varchar(50) DEFAULT NULL,"
+ " article_no varchar(50) DEFAULT NULL,"
+ " article_no_customer varchar(50) NULL,"
+ " barcode_no TEXT DEFAULT NULL,"
+ " line0 varchar(50) DEFAULT NULL,"
+ " line1 varchar(50) DEFAULT NULL,"
+ " line2 varchar(50) DEFAULT NULL,"
+ " line3 varchar(50) DEFAULT NULL,"
+ " line4 varchar(50) DEFAULT NULL,"
+ " line5 varchar(50) DEFAULT NULL,"
+ " line6 varchar(50) DEFAULT NULL,"
+ " line7 varchar(50) DEFAULT NULL,"
+ " line8 varchar(50) DEFAULT NULL,"
+ " line9 varchar(50) DEFAULT NULL,"
+ " PRIMARY KEY (uid)"
+ ");" );
+
+ // label_def
+ query.exec("DROP TABLE " TABLE_LABEL_DEF );
+ exec( &query, "CREATE TABLE " TABLE_LABEL_DEF " ("
+ " label_no " + drivers[driver]->autoIncrement() + ","
+ " manufacture varchar(255) DEFAULT NULL,"
+ " type varchar(255) DEFAULT NULL,"
+ " paper char(1) DEFAULT NULL,"
+ " gap_top NUMERIC(10,4) NULL,"
+ " gap_left NUMERIC(10,4) NULL,"
+ " height NUMERIC(10,4) NULL,"
+ " width NUMERIC(10,4) NULL,"
+ " gap_v NUMERIC(10,4) NULL,"
+ " gap_h NUMERIC(10,4) NULL,"
+ " number_h int DEFAULT NULL," //smalint(6)
+ " number_v int DEFAULT NULL," //smalint(6)
+ " paper_type varchar(30) DEFAULT NULL,"
+ " compatibility varchar(10) DEFAULT NULL," // keep compatibility with older versions, was "remark text"
+ " PRIMARY KEY (label_no)"
+ ");" );
+
+ dbase->close();
+ TQSqlDatabase::removeDatabase( database );
+ KMessageBox::information( 0, i18n("Created table ")+database+i18n(" successfully!") );
+
+ return true;
}
void SqlTables::importLabelDef()