PDA

View Full Version : database apps on mac



rogerholmes
22nd November 2009, 22:16
for the past two weeks i have been searching the internet and qtcentre, qtfourm etc and found conflicting information about Qt database access and mac.

do the database drivers in Qt 4.5 binary pagkage work "out of the box" on mac, i have found the windows package does, but i can not get them to work on mac (leopard).

this code works on windows "out of the box" .

it does not work on mac.

{
QSqlDatabase Db = QSqlDatabase::addDatabase("QODBC", "Calendar");

Db.setHostName("localhost");
Db.setDatabaseName("mySql");
Db.setUserName("root");

bool goodQuery;
bool validrec;
int x;
x=1;

if(Db.open()) // database is open
{
QSqlQuery query(Db);
query.exec("SELECT * from artist" );
goodQuery=query.isActive(); // this returns true
query.first(); // returns "Database Not Loaded"
validrec=query.isValid(); // this returns false
x=query.size(); // this returns -1

while(query.next()){
new QListWidgetItem(query.value(0).toString(), ui->listWidget); //this never executes
}
}
Db.close();
}

on mac
I can get column names but i can not get field data, at the query.first() line i get "database not loaded".

i am trying to access by odbc, i have confirmed the odbc drivers are installed correctley on mac by using other programs to query the database.

drivers are installed
On mac /Developer/Applications/Qt/plugins/sqldrivers
libqsqlite.dylib
libqsqlodbc.dylib
libqsqlpsql.dylib

I am at a loss, can someone point me in right direction. thanks in advance.:rolleyes: