PDA

View Full Version : QODBC driver



martisho
26th June 2009, 13:55
Hi everyone,

i have done a qt application who has to connect to another computer who has a Microsoft SQL Server Express Edition.

I have written this code:

bool DAO::connect(){
bool result=true;
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("10.2.9.15");
db.setDatabaseName("Test Bench (Prueba)");
db.setUserName("admin");
db.setPassword("admin");
result = db.open();
return result;
}

An i have created a new ODBC user dns with SQL Server Controller
I am using Visual Studio 2008, SQL Server Express Edition 2005, Windows Vista and qt4.4.3.

And when i execute my aplication this errors appears:

QSqlDatabase: QODBC driver not loaded
QSqlDatabase: available drivers: QSQLITE

In the directory C:\qt\4.4.3\qt-win-opensource-src-4.4.3\src\plugins\sqldrivers\odbc i have:

main.cpp
odbc.pro
qsql_odbc.cpp
qsql_odbc.h
qsqlodbc_resource.rc
qsqlodbcd_resource.rc

I have compiled qmake odbc.pro and the same error again.

I don´t know what i have to do, if i have to download ODBC driver please tell me where can i download it, because i haven´t found nothing.

Please help me.

Thank you very much.

lyuts
28th June 2009, 21:38
You need to compile odbc plugin as described in Qt Assistant.

ajg85
7th April 2010, 20:48
After compiling the odbc plugin be sure to copy libqsqlobdc.so (or .dll on windows) to your qtsdk/bin/sqldrivers/ and qtsdk/qt/plugins/sqldrivers directories so QT can find it and use it.