Originally Posted by
axel07
I'm getting frustated at it, do you know why?
The problem is in how QSqlDatabase handles the separators. E.g.:
QFile("e:/test.db");
// open will work db.setDatabaseName("e:/test.db"); // will not work, since it must be e:\test.db
QFile("e:/test.db"); // open will work
db.setDatabaseName("e:/test.db"); // will not work, since it must be e:\test.db
To copy to clipboard, switch view to plain text mode
So before setting a path to QSqlDatabase make following and it will work:
QString databaseFile
("e:/path/to/database/file.db");
databaseFile
= QDir::toNativeSeparators(info.
absoluteFilePath());
db.setDatabaseName(databaseFile);
QSqlDatabase db;
QString databaseFile("e:/path/to/database/file.db");
QFileInfo info(databaseFile);
databaseFile = QDir::toNativeSeparators(info.absoluteFilePath());
db.setDatabaseName(databaseFile);
To copy to clipboard, switch view to plain text mode
Bookmarks