找不到数据源名称且未指定默认驱动程序,C ++ MYSQL连接

时间:2019-02-17 20:13:40

标签: c++ odbc visual-c++-2012

我有一个Visual c ++ 2017应用程序,该应用程序连接到MySQL数据库。该项目使用CDatabase :: OpenEx和以下连接字符串:

ConnString.Format(_T("Driver={MySQL ODBC 5.3 Unicode 
Driver};Server=%s;Port=3306;Option=4;Database=dbname;Uid=%s;Pwd=%s"), 
ArgConnHost, ArgConnUser, ArgConnPassw);  // argument list used to fill in 
the details)
try
{
    bOpenresult = db2.OpenEx(ConnString, CDatabase::noOdbcDialog);
}
catch (CDBException* pEX)
{
    AfxMessageBox(pEX->m_strError);
    pEX->Delete();
}

这使我“未找到数据源名称且未指定默认驱动程序”

我的项目是Win32项目,我安装的驱动程序也是32bit,驱动程序名为“ MySQL ODBC 5.3 Unicode Driver”,我尝试使用其他名称,但问题仍然存在。 当我使用驱动程序中的“测试连接”按钮时,我获得了成功的连接(参见图片)。 之前,该项目在具有Windows 7的旧计算机上运行良好。现在,我不确定使用Windows 10,也许是另一个Visual Studio。

Driver_prtscr

0 个答案:

没有答案