Why do I get the "data source name not found and no default driver specified" message and how do I fix it?
P粉080643975
P粉080643975 2023-10-18 13:56:36
0
2
867

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?

P粉080643975
P粉080643975

reply all(2)
P粉147045274

In design mode, the value has been set to the property TFDConnection.ConnectionDefName Must be empty.

P粉221046425

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:

  1. The driver you are trying to use is not installed on your system
  2. The driver is installed but does not match the bitness of the code you are running
  3. You made an error entering the driver name

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 ⊞ Win R and enter: odbcad32.exe. Then check tab Drivers for installed drivers. The Name column 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 ⊞ Win R, 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:

DRIVER={DriverName};ParameterName1=ParameterValue1;ParameterNameN=ParameterValueN;

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 driver must exist 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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template