postgresql - 使用 ODBC 驱动程序连接 postgresql 的连接字符串是什么?

标签 postgresql

我目前正在处理连接 PostgreSQL 并将数据从该数据库检索到我的 .net 应用程序的任务,我使用的代码如下

OdbcConnection con = new OdbcConnection("Driver={PostgreSQL };Server=localhost;Port=2012;Database=DataCenter;Uid=postgres;Pwd=post@123;");

但它抛出一个 ODBException。请给我一个代码。

最佳答案

你可以试试:

Driver={PostgreSQL};Server=IP address;Port=5432;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

您绝对可以在这个网站上找到更多信息:http://www.connectionstrings.com/ 在您的情况下,特别是在此页面上:http://www.connectionstrings.com/postgre-sql#p51

如果它不能解决您的问题,那是因为问题不是来自连接字符串,而是您的 PostgreSQL 配置。您可能想检查您是否能够使用“psql”(例如)从您的客户端计算机连接到服务器。

问候

关于postgresql - 使用 ODBC 驱动程序连接 postgresql 的连接字符串是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11343628/

相关文章:

sql - 在 PostgreSQL 中获取两个日期之间的结果

postgresql - PostgREST 在子查询或 CTE 中使用限制和偏移量

postgresql - 启用 PostGIS 扩展错误

postgresql - 创建一个带有参数作为子选择的函数

postgresql - 我可以将 postgres JSON 列类型与 Strongloop Loopback 一起使用吗?

database - Postgresql 或其他数据库 : How to autosort rows and store position dynamically and efficiently?

SQL : transform union query to a single query

sql - 从 Django 查询 postgres 数据库以列出所有具有事件图书借阅(tab2)的用户(tab1)的最佳方法?

ruby-on-rails - 如何在 Arel 中对连接列进行类型转换

php - Postgresql 数据库在 MacOS Bash 上出现 PHP 服务器错误