Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection string doesnt work for PostgreSQL

I am using the following connection string structure in my web.config in order to connect to a PostgreSQL database using ODBC however I get an error:

Connection string

<add name="ApplicationODBCDefault" connectionString="Driver={PostgreSQL};Server=127.0.0.1;Port=5432;Database=dbname;Uid=name;Pwd=password;"/>

Error:

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

I have downloaded and installed both the 32 bit and 64 bit drivers for PostgreSQL ODBC from Here and it still isn't working. What could be the issue here?

like image 643
CSharpened Avatar asked May 17 '26 01:05

CSharpened


2 Answers

Instead of {PostgreSQL} use {PostgreSQL ANSI} or {PostgreSQL UNICODE}

Driver={PostgreSQL UNICODE};Server=127.0.0.1;Port=5432;Database=dbname;Uid=name;Pwd=password;

for more connection strings have a look at: http://www.connectionstrings.com/postgre-sql

You can also configure DSN using ODBC Data Source Administrator and then use created DSN name in ConnectionString:

DSN=dsn_name;Uid=name;Pwd=password;

Look at: https://www.connectionstrings.com/odbc-dsn/

like image 77
Michał Niklas Avatar answered May 19 '26 15:05

Michał Niklas


If you are using the 64 bits version of PostgreSQL, then you should use in the connection string:

Driver={PostgreSQL UNICODE(x64)};Server=127.0.0.1; .......

like image 20
lexes Avatar answered May 19 '26 16:05

lexes