hey all,
I'm using Qt4.4.1 and trying to connect to mysql database using the following code:
db.setHostName("acidalia");
db.setDatabaseName("customdb");
db.setUserName("mojito");
db.setPassword("J0a1m8");
bool ok = db.open();
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("acidalia");
db.setDatabaseName("customdb");
db.setUserName("mojito");
db.setPassword("J0a1m8");
bool ok = db.open();
To copy to clipboard, switch view to plain text mode
i also include
#include <QtSql>
#include <QSqlDatabase>
#include <QtSql>
#include <QSqlDatabase>
To copy to clipboard, switch view to plain text mode
but i get the following error:
src\mainwindowimpl.cpp: In member function `void MainWindowImpl::fileNew()':
src\mainwindowimpl.cpp:124: error: `QSqlDatabase' undeclared (first use this function)
src\mainwindowimpl.cpp:124: error: (Each undeclared identifier is reported only once for each function it appears in.)
src\mainwindowimpl.cpp:124: error: expected `;' before "db"
src\mainwindowimpl.cpp:125: error: `db' undeclared (first use this function)
src\mainwindowimpl.cpp:129: warning: unused variable 'ok'
mingw32-make.exe[1]: *** [build/mainwindowimpl.o] Error 1
e:\qt\MinGW\bin\mingw32-make.exe: *** [release] Error 2
src\mainwindowimpl.cpp: In member function `void MainWindowImpl::fileNew()':
src\mainwindowimpl.cpp:124: error: `QSqlDatabase' undeclared (first use this function)
src\mainwindowimpl.cpp:124: error: (Each undeclared identifier is reported only once for each function it appears in.)
src\mainwindowimpl.cpp:124: error: expected `;' before "db"
src\mainwindowimpl.cpp:125: error: `db' undeclared (first use this function)
src\mainwindowimpl.cpp:129: warning: unused variable 'ok'
mingw32-make.exe[1]: *** [build/mainwindowimpl.o] Error 1
e:\qt\MinGW\bin\mingw32-make.exe: *** [release] Error 2
To copy to clipboard, switch view to plain text mode
i know it's been answered before in this forum here: http://www.qtcentre.org/forum/f-newb...blem-5861.html
but i followed the solution and yet it didn't work for me.
Any ideas!?
thanks in advance.
Bookmarks