PostgreSQL Connection String with ODBC driver in C#, Keyword not supported: driver

戏子无情 提交于 2019-12-12 01:27:40

问题


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:


回答1:


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



来源:https://stackoverflow.com/questions/41076042/postgresql-connection-string-with-odbc-driver-in-c-keyword-not-supported-driv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!