4

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?

2
  • 2
    Could you try if your connection works with ODBC Manager? And just to ask. Why not use npgsql managed provider? Commented Apr 2, 2012 at 11:09
  • Where can I find this? Npgsql cannot be used as the solution must be database agnostic. Long story. Tried the OLE route but couldnt get Npgsql to play nice with OLE. ODBC is the next route I want to explore. Commented Apr 2, 2012 at 11:11

2 Answers 2

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/

Sign up to request clarification or add additional context in comments.

3 Comments

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=Guest;Pwd=******;"
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 !
I added info about using DSN. It may be easier.
1

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

1 Comment

If we develop with X64, use this code work well. How about i build this code and use at i386 ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.