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