How to find the ODBC driver name for a connection string?
Asked Answered
R

2

6

Whenever I use ODBC drivers with a full connection string, and not just a DSN entry, I often get an error similar to this

Data source name not found and no default driver specified

I have the correct syntax of the connection string (or so the Internet says), but I suspect I don't know the correct name for the current version of the ODBC driver I am using

How do I find the correct name, for either 32 or 64 bit?

Reverberator answered 21/10, 2015 at 8:16 Comment(0)
R
10

Use the ODBC Data Source Administrator app. Make sure you use the 32 bit or the 64 bit version depending on your applications build target. Then select the "File DSN" tab

ODBC Data Source Administrator

Click the "Add" button, and select the driver you have installed

"Add" button

Then click the "Advanced" button

"Advanced" button

You can then copy and paste the correct driver name, and cancel out of the ODBC Data Source Administrator app

e.g.

DRIVER={PostgreSQL ODBC Driver(UNICODE)}

Add the rest of the parameters required, and you will have a working ODBC connection string for the currently installed version of the driver

e.g.

Driver={PostgreSQL ODBC Driver(UNICODE)};Server=ruru.nz;Port=5432;Database=TheInternet;Uid=tfd;Pwd=p455w0rd;

Enjoy :-)

Reverberator answered 21/10, 2015 at 8:18 Comment(2)
I followed most of these steps, buw how do you get the Server, Port, Database and Uid?Medellin
Hi @bernando_vialli, as the article title says this is "How to find the ODBC driver name" not how to get the db info. If you search on the site for the correct topic surely you will find what are you looking for.Polemoniaceous
M
1

Get-OdbcDsn -Name "[dsn-name]" -DsnType "[system|user|file]" -Platform "64-bit"

You can use powershell to get it as well. And possibly build the full connection string.

$dsn = Get-OdbcDsn -Name "dsn-plus" -DsnType "user" -Platform "64-bit"
$dsn
$dsn.DriverName
#$dsn.Attribute

$connecton_string = 'driver="' + $dsn.DriverName + '";'
foreach ($key in $dsn.Attribute.Keys) {
    if ([string]::IsNullOrWhiteSpace($dsn.Attribute[$key])) {
        $connecton_string = $connecton_string + $key + ";";
    } else {
        $connecton_string = $connecton_string + $key + "=" + $dsn.Attribute[$key] + ";";
    }
}

$connecton_string
Metathesis answered 9/4, 2021 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.