How could I properly connect to Excel file using QODBC/QODBC3 Qt drivers?
At firs I built a driver like that (in cmd)
>cd %QTPATH%\src\plugins\sqldrivers\odbc
>qmake odbc.pro
>nmake
then qsqlodbc4.dll file has been created in %QTPATH%\plugins\sqldrivers
I used this code
#include <QApplication>
#include <QtGui>
#include <QtSql>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
//QComboBox myCombo;
//excel stuff
QSqlDatabase dbExcel = QSqlDatabase::addDatabase("QODBC","dbExcel");
// i thought mayde that would work
// dbExcel.setDatabaseName("C:\databases\test.xlsx");
//i tried connection string too
dbExcel.setDatabaseName(QString("DRIVER={Microsoft Excel Driver (*.xlsx)}; READONLY=FALSE; FIL={MS Excel}; DBQ=C:\databases\test.xlsx"));
if(!dbExcel.open())
{
QSqlError er = dbExcel.lastError();
QMessageBox::information(0, "Error", er.text());
}
//...................
return app.exec();
}
and there I cathed that error (it translates like:
[Microsoft][ODBC driver manager] Data source not found and default driver not set. QODBC3: Unable to connect
)

UPD
Also it says that drivers are avalible
QSqlDatabase: available drivers: QIBASE QSQLITE QODBC3 QODBC
dbExcel.setDatabaseName(QString("DRIVER={Mic....dbExcel.setDatabaseName(QString("DRIVER={Microsoft Excel Driver (*.xlsx)}; READONLY=FALSE; FIL={MS Excel}; DBQ=C:\databases\test.xlsx"));but it didn't worked. also made it uncommented in code to not confuse people anymore :)