Connection string doesnt work for PostgreSQL

22,190

Solution 1

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/

Solution 2

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; .......

Share:
22,190
CSharpened
Author by

CSharpened

Currently working as a Software Engineer for LJT Systems Ltd

Updated on March 04, 2020

Comments

  • CSharpened
    CSharpened about 4 years

    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?

  • Pamungkas Jayuda
    Pamungkas Jayuda about 8 years
    If we develop with X64, use this code work well. How about i build this code and use at i386 ?
  • PiotrKowalski
    PiotrKowalski over 7 years
    With this I got "Keyword not supported: driver". Any ideas why? My code looks like this: "Driver={PostgreSQL UNICODE};Server=*****;Port=5432;Database=IdM_Person;Uid=Gues‌​t;Pwd=******;"
  • Elias Ghali
    Elias Ghali about 4 years
    Hey, I keep getting this error ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, although if I use Server Explorer, it connects using PostgreSQL driver, but not with this connection string !
  • Michał Niklas
    Michał Niklas about 4 years
    I added info about using DSN. It may be easier.