QODBC driver not loaded
-
"On Windows an ODBC driver manager should be installed by default."
i have windows how can i check ODBC is installed or not? -
It is (as long as you use something >= XP), you must configure an ODBC connection: http://msdn.microsoft.com/en-us/library/ca6axakh(v=vs.80).aspx on each computer that should connect to the database via ODBC.
-
-
Please be so kind and provide some information.
What Windows version do you use?
Did you test the ODBC connection? How is it configured? Which driver is configured therein?
Can you connect via OSQL?
Do you still use the connection data from you initial post? If yes, it won't work. If no, what do you use now?
What Qt library version do you use?
32bit or 64bit?
The latter one could be important, because the "database driver must exist":http://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/allen_brown_bentleys_blog/archive/2009/03/04/32-bit-database-connectivity-on-a-64-bit-os.aspx for the same "bitness" of your application.After all that is checked, it could still be a "bug":https://bugreports.qt-project.org.
-
[quote author="zidom" date="1350898907"]I add odbc
!http://dl.2rialy.ir/ZiDoM-Ups/91/odbc.JPG(odbc)!
but i still have this error
!http://dl.2rialy.ir/ZiDoM-Ups/91/sql.JPG(error)![/quote]
When I did this I also specified DSN in the string I passed to setDatabaseName(). In your case that would be ZiDoM (according to your pic) . The string should look smthng like this:
@"DRIVER={SQL Native Client};DSN='ZiDoM';SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;"@
P.S. I am not quite sure about the string syntax. I will post the one I used tommorow when I get to work. -
Thanks because of helping
i use windows 7 64bit
i use qt 4.8
qt creator 2.5 based on 32 bit qt 4.8
i used DSN='ZiDoM' but didn't work still same error and i still use the code that i wrote in first post -
This is the string that works fine for me:
@QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={SQL Server};DSN='PlaneTraj';SERVER=DB-SERVER;DATABASE=RealPlanesData;");@
My user DSN (that I added using C:\Windows\SysWOW64\odbcad32.exe) name is PlaneTraj and its Driver is SQL Server; in your case these are ZiDoM and SQL Server (according to your pic).
Try using Driver={SQL Server} instead of yours DRIVER={SQL Native Client} -
i tried that but still same error
i tried
QStringList driversList = QSqlDatabase::drivers();
qDebug() << "drivers list= " << driversList;
to see the drivers but there is no QODBC -
Look inside the folder located somewhere like: C:\Qt\4.8.2\plugins\sqldrivers. See if it contains ODBC drivers.
I have the following files in this folder:
qsqlite4.dll qsqlite4.exp qsqlite4.lib qsqlited4.dll
qsqlited4.exp qsqlited4.ilk qsqlited4.lib qsqlited4.pdb
qsqlodbc4.dll qsqlodbc4.lib qsqlodbcd4.dll qsqlodbcd4.lib
qsqlpsql4.dll qsqlpsql4.lib qsqlpsqld4.dll qsqlpsqld -
I have them except the *.exp
-
looks like your app for some reason can't locate theese files. have a look at this http://doc.qt.digia.com/latest/deployment-plugins.html
-
you mean i should have those *.exp files?
-
no, I don't know what .exp files are for, but I don't think it's the problem. I mean if you have all the rest qsqlodbc files in \sqldrivers and QSqlDatabase::drivers() doesn't give QODBC in the list, then maybe your app can't locate them in this folder?
does QSqlDatabase::drivers() return anything or the list is epmpty? if it does what is it? -
it returns QSQLITE
-
The only thing I can think of: make a backup of your \sqldrivers or just rename it and try to replace it with mine:
http://zalil.ru/33883387/554c07b0.508763d8/sqldrivers.zip
I am using qt4.8.3 though -
Thanks a lot for your helps
but still same error i am confused -
Hi
i made some changes
then i could connect to database
@#include <QCoreApplication>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setHostName("LOCALHOST\SQLEXPRESS");
db.setDatabaseName("mydsn32");
if(db.open())
{
qDebug() << "Opened";
db.close();
}
else
{
qDebug() <<"Error = "<<db.lastError();
}
return a.exec();
}
@
i made a dsn and i used QSQLITE but i can not still use QODBC but its better than nothing -
Theres probably some issues with ODBC drivers on your OS
-
Now I found the time to test it on my own.
System: Windows7, Qt SDK version 1.2.1 with Qt libraries version 4.8.1 (offline installer).I've created a test database on a Microsoft SQL Server Express server (which basically means that the database does not run on my development machine).
With "C:\Windows\SysWOW64\odbcad32.exe" a user DSN was set up using "Sql Server Native Client 10.0".Checked connection via ODVC from comandline
@C:\Users\username>osql -D QtODBCDSN -U qtodbclogin -P passw0rd
1>
@Ok, that works, now the Qt part.
@
#include <QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql/QODBCDriver>
#include <QtSql/QSqlError>
#include <QDebug>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);qDebug() << QSqlDatabase::drivers(); QSqlDatabase dataBase = QSqlDatabase::addDatabase("QODBC"); // using the DSN, created with odbcad32.exe here! dataBase.setDatabaseName("QtODBCDSN"); dataBase.setUserName("qtodbclogin"); dataBase.setPassword("passw0rd"); if(dataBase.open()) { qDebug() << "Database is open."; dataBase.close(); } else qDebug() << "Could not open database, error=" << dataBase.lastError(); return a.exec();
}
@Output:
@
("QSQLITE", "QODBC3", "QODBC")
Database is open.
@Maybe that helps to check, if your system is corrupt:
@
Directory of C:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtSql25.09.2012 10:48 <DIR> .
25.09.2012 10:48 <DIR> ..
25.09.2012 10:48 23 QDB2Driver
25.09.2012 10:48 23 QDB2Result
25.09.2012 10:48 25 QIBaseDriver
25.09.2012 10:48 25 QIBaseResult
25.09.2012 10:48 25 QMYSQLDriver
25.09.2012 10:48 25 QMYSQLResult
25.09.2012 10:48 23 QOCIDriver
25.09.2012 10:48 23 QOCIResult
25.09.2012 10:48 24 QODBCDriver
25.09.2012 10:48 24 QODBCResult
25.09.2012 10:48 24 QPSQLDriver
25.09.2012 10:48 24 QPSQLResult
25.09.2012 10:48 2.964 qsql.h
25.09.2012 10:48 27 QSqlDatabase
25.09.2012 10:48 5.496 qsqldatabase.h
25.09.2012 10:48 25 QSqlDriver
25.09.2012 10:48 6.475 qsqldriver.h
25.09.2012 10:48 27 QSqlDriverCreator
25.09.2012 10:48 27 QSqlDriverCreatorBase
25.09.2012 10:48 31 QSqlDriverFactoryInterface
25.09.2012 10:48 31 QSqlDriverPlugin
25.09.2012 10:48 2.711 qsqldriverplugin.h
25.09.2012 10:48 24 QSqlError
25.09.2012 10:48 3.218 qsqlerror.h
25.09.2012 10:48 24 QSqlField
25.09.2012 10:48 3.742 qsqlfield.h
25.09.2012 10:48 24 QSqlIndex
25.09.2012 10:48 3.179 qsqlindex.h
25.09.2012 10:48 27 QSQLite2Driver
25.09.2012 10:48 27 QSQLite2Result
25.09.2012 10:48 26 QSQLiteDriver
25.09.2012 10:48 26 QSQLiteResult
25.09.2012 10:48 24 QSqlQuery
25.09.2012 10:48 4.206 qsqlquery.h
25.09.2012 10:48 29 QSqlQueryModel
25.09.2012 10:48 3.650 qsqlquerymodel.h
25.09.2012 10:48 25 QSqlRecord
25.09.2012 10:48 4.026 qsqlrecord.h
25.09.2012 10:48 39 QSqlRelation
25.09.2012 10:48 37 QSqlRelationalDelegate
25.09.2012 10:48 4.594 qsqlrelationaldelegate.h
25.09.2012 10:48 39 QSqlRelationalTableModel
25.09.2012 10:48 3.923 qsqlrelationaltablemodel.h
25.09.2012 10:48 25 QSqlResult
25.09.2012 10:48 5.050 qsqlresult.h
25.09.2012 10:48 29 QSqlTableModel
25.09.2012 10:48 4.699 qsqltablemodel.h
25.09.2012 10:48 3.868 qsql_db2.h
25.09.2012 10:48 4.311 qsql_ibase.h
25.09.2012 10:48 4.318 qsql_mysql.h
25.09.2012 10:48 4.122 qsql_oci.h
25.09.2012 10:48 4.570 qsql_odbc.h
25.09.2012 10:48 4.666 qsql_psql.h
25.09.2012 10:48 3.886 qsql_sqlite.h
25.09.2012 10:48 4.025 qsql_sqlite2.h
25.09.2012 10:48 4.023 qsql_symsql.h
25.09.2012 10:48 4.089 qsql_tds.h
25.09.2012 10:48 26 QSymSQLDriver
25.09.2012 10:48 26 QSymSQLResult
25.09.2012 10:48 23 QTDSDriver
25.09.2012 10:48 23 QTDSResult
25.09.2012 10:48 470 QtSql
62 File(s) 101.260 bytes
2 Dir(s) 32.258.682.880 bytes free@
@
Directory of C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\sqldrivers25.09.2012 10:49 <DIR> .
25.09.2012 10:49 <DIR> ..
25.09.2012 10:49 527.360 qsqlite4.dll
25.09.2012 10:49 1.872.165 qsqlited4.dll
25.09.2012 10:49 163.840 qsqlodbc4.dll
25.09.2012 10:49 997.135 qsqlodbcd4.dll
4 File(s) 3.560.500 bytes
2 Dir(s) 32.258.682.880 bytes free
@ -
Hi
thanks for pursuing my problem i have problem in first part
bq. C:\Users\username>osql -D QtODBCDSN -U qtodbclogin -P passw0rd
it says
[ODBC Driver Manager] Data source name not found and no default driver
specified