How to connect to a ODBC database on windows?

ε祈祈猫儿з 提交于 2020-01-14 06:06:35

问题


I want to connect to a ODBC database using Java/.NET. When I try to connect to the database, I get errors like:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Why is this? What I can I do to make the connection succeed?


回答1:


Errors while connecting to a ODBC database can cause some headache here is my list of things to check when such an error occurs:

  1. Bitness (32/64bit) Issues

    Check you are running with the same bitness (32/64bit) as the ODBC driver. Most of the time is it the bitness causing problems. Usually most ODBC drivers are shipped as 32bit. At least all Microsoft Office (Excel, Access, CSV, etc.) are only shipped as 32bit drivers. So you process MUST run as 32bit, too. There simply is no way arround this. You can check if your process is running as 32bit by looking at the taskmanagers process list. If there is a *32 behind the process name it indicates that it is running in 32bit mode

  2. Wrong user account

    Make sure you are running your process as a the same user that was used to create the ODBC configuration. The is a difference between user and system DSNs. The user ones are tied to specific user accounts. So if your app is running as a windows service running under the default local SYSTEM user it might simply not see the ODBC configuration.


If you found any other case where this error occured, please add it to this answer. I would like one definitive answer for all ODBC issues that people are seeking day to day.



来源:https://stackoverflow.com/questions/36793610/how-to-connect-to-a-odbc-database-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!