1

Lately I've been trying to connect a PostgreSQL 9.6 database on my C# project but I've been struggling setting up the connection string correctly due to "Keyword not supported:driver".

After having read tons of information, I downloaded the ODBC.NET, I registered PostgreSQL in ODBC Data Sources (32x), referenced the Microsoft.Data.Odbc.dll in my project's directory and managed to have a successful connection with my database in the Visual Studio's Ultimate 2013, but when it came to accessing the data something went wrong.

This is my connection string and a glimpse of my project:

Furthermore this is my data source information:

enter image description here

2
  • Out of curiosity, why not use Npgsql? Commented Jan 11, 2017 at 4:05
  • @Hambone At last switched everything to SqlServer and solved all my problems! Commented Jan 16, 2017 at 12:09

1 Answer 1

2

If you want to use ODBC to connect to PostgreSQL database use OdbcConnection

You can then instantiate a connection using DSN as ODBC data source identifier.

OdbcConnection DbConnection = new OdbcConnection("DSN=PostgreSQL30");

as specified here

There are also other ways to connect to PostreSQL without using ODBC driver. You might want to look at Npgsql .net library or EntityFramework with Npgsql library. More info about usage can be found here

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.