this is not a difficult thing. just c&p from the docs:
#include <QtGui>
#include <QtSql>
int main(int argc, char *argv[])
{
db.setHostName("acidalia");
db.setDatabaseName("customdb");
db.setUserName("mojito");
db.setPassword("J0a1m8");
bool ok = db.open();
if(ok)
{
QSqlQuery query
("SELECT country FROM artist");
while (query.next())
{
QString country
= query.
value(0).
toString();
qWarning() << country;
}
}
return app.exec();
}
#include <QtGui>
#include <QtSql>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("acidalia");
db.setDatabaseName("customdb");
db.setUserName("mojito");
db.setPassword("J0a1m8");
bool ok = db.open();
if(ok)
{
QSqlQuery query("SELECT country FROM artist");
while (query.next())
{
QString country = query.value(0).toString();
qWarning() << country;
}
}
return app.exec();
}
To copy to clipboard, switch view to plain text mode
By reading the docs about QSqlDatabase you should be able to connect via ODBC.
Bookmarks