The database reported an error: [unixODBC][Driver Manager]Data Source name not found, and no default driver specified
如下所示,QT应用程序尝试连接DBF类型的数据库文件(.dbf
),当我们尝试执行应用程序时,我们得到了上述错误。
QSqlDatabase db;
db = QSqlDatabase::addDatabase("QODBC");
QString str("DRIVER={Microsoft dBase Driver (*.dbf)}; DBQ=/path/to/dbf/files");
db.setDatabaseName(str);
if(db.open())
{
...
}
else
{
...// Failure
}
推荐链接(https://www.easysoft.com/support/kb/kb01039.html)并按照以下步骤操作:
odbc.ini
和odbcinst.ini
包含相应的内容。ODBCSYSINI
,ODBCINSTINI
和ODBCINI
/etc/odbc.ini
,/etc/odbcinst.ini
和/home/user/.odbc.ini
[unixODBC][Driver Manager]Data Source name not found, and no default driver specified
请查找odbc.ini
和odbcinst.ini
odbc.ini
档案:[ODBC Data Sources]
TestODBC=MyODBCDriver
[TestODBC]
Driver=path/to/driver file
DataDirectory=path/to/where my dbf files resides
[Default]
Driver=path/to/driverfile
DataDirectory=path/to/where my dbf files resides
odbcinst.ini
档案:[ODBC Drivers]
MyODBCDRIVER=Installed
[MyODBCDriver]
Description=ODBC Driver
Driver=/path/to Driver file
[ODBC]
Trace = Yes
请提供解决问题的任何建议或解决方案