Hi,
I'm trying to connect to my database whit the following code:
#include <QSqlDatabase>
...
db.setHostName("myhost");
db.setDatabaseName("mydb");
db.setUserName("myuser");
db.setPassword("mypass");
db.open();
#include <QSqlDatabase>
...
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("myhost");
db.setDatabaseName("mydb");
db.setUserName("myuser");
db.setPassword("mypass");
db.open();
To copy to clipboard, switch view to plain text mode
but I'm getting this error:
main.cpp:5:24: QSqlDatabase: No such file or directory
main.cpp: In function `int qMain(int, char**)':
main.cpp:17: error: `QSqlDatabase' undeclared (first use this function)
main.cpp:17: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:17: error: expected `;' before "db"
main.cpp:18: error: `db' undeclared (first use this function)
mingw32-make[1]: *** [debug\main.o] Error 1
Bookmarks