PDA

View Full Version : Mac OS + Qt 4.6.2, QODBC3: Unable to connect



Royceybaby
7th May 2010, 21:42
Hi,

I am trying to get an ODBC connection working on my new macbook in Qt, but I am coming up with the following error.

" QODBC3: Unable to connect"

This is the small piece of test code I am using:


#include <QCoreApplication>
#include <QSqlDatabase>
#include <QSqlError>
#include <QDebug>

int main(int argc, char* argv[]) {
QCoreApplication app(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
// Also, try replacing the two previous lines with:
// QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
// No need to set any version option in that case
db.setDatabaseName("DRIVER=FreeTDS;SERVER=192.168.16.5;Port=1433;DATAB ASE=db_test;TDS_Version=8.0;uid=SomeUser;pwd=SomeP assword");
bool r = db.open();
if (!r) {
qDebug() << db.lastError().text();
}
else {
qDebug() << "OK!";
}
}

Here are a couple of parts of the trace log.


[000000.000302]
test A0B4C4E0 ENTER SQLDriverConnect
SQLHDBC 0xf19ff0
SQLPOINTER 0x0
SQLCHAR * 0xf1a080
| DRIVER=FreeTDS;SERVER=192.168.16.5;Port= |
| 1433;DATABASE=db_test;TDS_Ve |
| rsion=8.0;uid=SomeUser;pwd=********* |
SQLSMALLINT 119
SQLCHAR * 0xbffff48c
SQLSMALLINT 1024
SQLSMALLINT * 0xbffff8ec
SQLUSMALLINT 0 (SQL_DRIVER_NOPROMPT)

[000000.000722]
test A0B4C4E0 EXIT SQLDriverConnect with return code -1 (SQL_ERROR)
SQLHDBC 0xf19ff0
SQLPOINTER 0x0
SQLCHAR * 0xf1a080
SQLSMALLINT 119
SQLCHAR * 0xbffff48c
SQLSMALLINT 1024
SQLSMALLINT * 0xbffff8ec
SQLUSMALLINT 0 (SQL_DRIVER_NOPROMPT)


Can anybody help me?

Thanks,
Royce

Royceybaby
8th May 2010, 11:15
Ok this seems to be a bug in Qt 4.6.2, I have installed Qt 4.7.0-beta1 and it now seems to work.

The tip off was this link. (http://bugreports.qt.nokia.com/browse/QTBUG-3114)

It should be fixed in Qt 4.6.3 when that is ready.

Royce