I had a small problem and so, I was playing a lttle bit with the source.
Can anobody tell my, why in the following code dbMandant.open() returns true, even if there is no host, no databaseName specified??
//dbMandant.setHostName( dbHost );
//dbMandant.setDatabaseName( dbName );
dbMandant.setUserName( dbUser );
dbMandant.setPassword( dbPasswd );
//dbMandant.setPort( dbPort.toInt() );
qDebug() << dbMandant;
qDebug() << dbMandant.open();
QSqlDatabase dbMandant = QSqlDatabase::addDatabase( dbDriver, "mandant" );
//dbMandant.setHostName( dbHost );
//dbMandant.setDatabaseName( dbName );
dbMandant.setUserName( dbUser );
dbMandant.setPassword( dbPasswd );
//dbMandant.setPort( dbPort.toInt() );
qDebug() << dbMandant;
qDebug() << dbMandant.open();
To copy to clipboard, switch view to plain text mode
Here ist the output from qDebug:
QSqlDatabase(driver=""QMYSQL"", database="""", host="""", port=-1, user=""root"", open=false)
true
The manual says:
bool QSqlDatabase:
pen ()
opens the database connection using the current connection values. Returns true on success; otherwise returns false.
I don't have a connection value for setDatabaseName, why open() returns true?
Regards Guenther
Bookmarks