PDA

View Full Version : ODBC Oracle. Unable to connect to database



egil
17th October 2008, 13:22
Using Qt 4.4.3, Mingw, Windows XP, Oracle 9.2

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DataSourceName");
db.setUserName("username");
db.setPassword("password");

db.open gives error message:
[Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed QODBC3: Unable to connect

When I misspell "DataSourceName", I get the error ..... Data source name not found ....., so that name is obviously working.
Testing the connection in "Microsoft ODBC Adminstrator" works ok.
Empty username and password makes no difference.

Trace file from ODBC Adminstrator attached. (trace.txt)

(Until now we have used a Delphi program with Borland BDE, but are migrating to Qt4 and C++.)

SunnySan
17th October 2008, 13:36
did u include the "sqlodbc.dll" (or similar name) in the qt\4.4\plugins\sqldriver directory?

egil
17th October 2008, 13:46
Hello

I built qsqlodbc4.dll and qsqlodbcd4.dll (they are now in ...\plugins\sqldrivers) as described in http://doc.trolltech.com/3.3/sql-driver.html#QODBC3