When trying to write a program on Windows that connects to a database via ODBC, the following error occurs:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
I'm sure my code is correct. It can even run on another computer.
Why am I getting this error? How can I fix it?
In design mode, the value has been set to the property
TFDConnection.ConnectionDefName
Must be empty.What causes this error?
Simply put, the error message tells you that the ODBC Driver Manager cannot find the driver you specified in the connection string or DSN.
There may be 3 common reasons for this:
How do I check which drivers are installed on my system?
You can check the drivers installed on your system by going to the ODBC Data Source Administrator. To open it, press⊞ WinRand enter:
odbcad32.exe
. Then check tabDriversfor installed drivers.The Namecolumn indicates the exact name you should use in the connection string or DSN.If you are using 64-bit Windows, only the files installed on your system. To see which 32-bit drivers are installed, press⊞ WinR, then enter:
C:\Windows\SysWOW64\odbcad32.exe code>, then again Go to the "Drivers" tab.
The driver has been installed, but the number of bits may be wrong. What should I do?
Then you have two options, either adjust the number of bits the program runs at, or install a driver with a different number of bits.
Some drivers installed by default on Windows only have 32-bit variants. These cannot be used with 64-bit programs.
You can usually identify the number of bits a program is running in Task Manager. In Windows 10, all 32-bit programs have (32-bit) appended to their names. If it's not there, you're probably running a 64-bit program, and most modern programming languages and environments run on 64-bit by default, but allow you to switch to 32-bit. However, the specific details of different programming languages are beyond the scope of this question.
How to verify that I did not enter the wrong driver name?
The ODBC connection string looks like this:
If the driver name part may contain special characters, it needs to be separated by braces and needs to match the installed driver name exactly (as shown in the ODBC Data Source Administrator), including spaces and typographical characters, but Exclude capital letters.
Please note that for deployed code, the drivermustexist on the computer/server running the code.
I don’t have the driver, or the bitness is wrong, where can I get the correct driver?
It depends on which driver you want to use.
List of common drivers and download locations (all 32-bit and 64-bit at the same URL):
If the driver you want to use is not listed, you can usually easily find the location using Google.