Allow table creation if database user only has access to the existing KBarcode table

(cherry picked from commit 9e61fbb21f)
r14.0.x r14.0.3
Timothy Pearson 9 years ago committed by Slávek Banko
parent a38797c8c9
commit 739f1e63fd

@ -157,7 +157,6 @@ bool SqlTables::newTables( const TQString & username, const TQString & password,
dbase->setHostName( hostname ); dbase->setHostName( hostname );
if (dbase->open()) { if (dbase->open()) {
if ((driver != "QSQLITE") && (driver != "TQSQLITE")) if ((driver != "QSQLITE") && (driver != "TQSQLITE"))
{ {
bool found = false; bool found = false;
@ -177,6 +176,14 @@ bool SqlTables::newTables( const TQString & username, const TQString & password,
} }
dbase->close(); dbase->close();
TQSqlDatabase::removeDatabase(drivers[driver]->initdb( database )); TQSqlDatabase::removeDatabase(drivers[driver]->initdb( database ));
} else {
TQSqlError dbError = dbase->lastError();
dbase->close();
TQSqlDatabase::removeDatabase(drivers[driver]->initdb( database ));
if (KMessageBox::warningContinueCancel(0, i18n("<qt>Can't connect to database to create table.") + "<p>" + dbError.driverText() + "<br>" + dbError.databaseText() + i18n("<br>You can continue if the table exists already.</qt>")) == KMessageBox::Cancel) {
return false;
}
}
// The database is created, now connect to the one specified by the user // The database is created, now connect to the one specified by the user
dbase = TQSqlDatabase::addDatabase(driver, database ); dbase = TQSqlDatabase::addDatabase(driver, database );
@ -190,7 +197,6 @@ bool SqlTables::newTables( const TQString & username, const TQString & password,
return false; return false;
} }
TQSqlQuery query( NULL, dbase ); TQSqlQuery query( NULL, dbase );
// barcode_basic // barcode_basic
@ -268,13 +274,6 @@ bool SqlTables::newTables( const TQString & username, const TQString & password,
dbase->close(); dbase->close();
TQSqlDatabase::removeDatabase( database ); TQSqlDatabase::removeDatabase( database );
KMessageBox::information( 0, i18n("Created table ")+database+i18n(" successfully!") ); KMessageBox::information( 0, i18n("Created table ")+database+i18n(" successfully!") );
} else {
TQSqlError dbError = dbase->lastError();
dbase->close();
TQSqlDatabase::removeDatabase(drivers[driver]->initdb( database ));
KMessageBox::sorry(0, i18n("Can't connect to database.") + "\n" + dbError.driverText() + "\n" + dbError.databaseText());
return false;
}
return true; return true;
} }

Loading…
Cancel
Save