postgresql 如何将 C# 与 Postgres 连接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1245554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 22:19:15  来源:igfitidea点击:

How do I connect C# with Postgres?

postgresqlc#-3.0

提问by Goows

How do I Connect C# with Postgres? I download the npgsql data provider but couldn't make it work. Are there more examples than the ones in the Postgres site?

如何将 C# 与 Postgres 连接起来?我下载了 npgsql 数据提供程序,但无法使其工作。是否有比 Postgres 站点中的示例更多的示例?

Cheers,

干杯,

回答by Andrew Hare

Here is a walkthrough, Using PostgreSQL in your C# (.NET) application (An introduction):

这是一个演练,在您的 C# (.NET) 应用程序中使用 PostgreSQL(简介)

In this article, I would like to show you the basics of using a PostgreSQL database in your .NET application. The reason why I'm doing this is the lack of PostgreSQL articles on CodeProject despite the fact that it is a very good RDBMS. I have used PostgreSQL back in the days when PHP was my main programming language, and I thought.... well, why not use it in my C# application.

在本文中,我想向您展示在 .NET 应用程序中使用 PostgreSQL 数据库的基础知识。我这样做的原因是缺乏关于 CodeProject 的 PostgreSQL 文章,尽管它是一个非常好的 RDBMS。在 PHP 是我的主要编程语言的日子里,我使用过 PostgreSQL,我想……好吧,为什么不在我的 C# 应用程序中使用它。

Other than that you will need to give us some specific problems that you are having so that we can help diagnose the problem.

除此之外,您需要向我们提供一些您遇到的具体问题,以便我们帮助诊断问题。

回答by Randolpho

You want the NPGSQLlibrary. Your only other alternative is ODBC.

您需要NPGSQL库。您唯一的其他选择是 ODBC。

回答by fkerrigan

If you want an recent copy of npgsql, then go here

如果你想要一份 npgsql 的最新副本,那么去这里

http://www.npgsql.org/

http://www.npgsql.org/

This can be installed via package manager console as

这可以通过包管理器控制台安装为

PM> Install-Package Npgsql

PM> 安装包 Npgsql