c# - 连接字符串不适用于 PostgreSQL

标签 c# postgresql odbc

我在我的 web.config 中使用以下连接字符串结构,以便使用 ODBC 连接到 PostgreSQL 数据库,但是我收到错误:

连接字符串

<add name="ApplicationODBCDefault" connectionString="Driver={PostgreSQL};Server=127.0.0.1;Port=5432;Database=dbname;Uid=name;Pwd=password;"/>

错误:

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

我已经从 Here 下载并安装了 PostgreSQL ODBC 的 32 位和 64 位驱动程序。它仍然无法正常工作。这可能是什么问题?

最佳答案

使用 {PostgreSQL ANSI}{PostgreSQL UNICODE} 代替 {PostgreSQL}

Driver={PostgreSQL UNICODE};Server=127.0.0.1;Port=5432;Database=dbname;Uid=name;Pwd=password;

有关更多连接字符串,请查看:http://www.connectionstrings.com/postgre-sql

您还可以使用 ODBC 数据源管理器配置 DSN,然后在 ConnectionString 中使用创建的 DSN 名称:

DSN=dsn_name;Uid=name;Pwd=password;

查看:https://www.connectionstrings.com/odbc-dsn/

关于c# - 连接字符串不适用于 PostgreSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9975180/

相关文章:

c# - Xamarin 上的 WebHeaderCollection 和 HttpWebRequest

javascript - 是否允许多次重复使用 pg QueryFile

json - FROM 子句中的 PostgreSQL json_array_elements - 为什么这不是笛卡尔连接?

postgresql - 两列之间唯一

c# - 你调用的对象是空的。但属性是可访问的

c# - 如何在 C#/WPF 中以编程方式访问 Windows Media Player 库?

c# - 将自定义类型的变量传递给自定义 MSBuild 任务

python - 使用 Teradata 模块将 Python 与 Teradata 连接

r - 在函数内调用 `odbc` 连接未显示在 RStudio 连接 Pane 中

linux - 无法在 Ubuntu 16.04 上使用 Go 连接到 NetSuite ODBC