连接字符串不适用于 PostgreSQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9975180/
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
Connection string doesnt work for PostgreSQL
提问by CSharpened
I am using the following connection string structure in my web.config in order to connect to a PostgreSQL database using ODBC however I get an error:
我在我的 web.config 中使用以下连接字符串结构,以便使用 ODBC 连接到 PostgreSQL 数据库,但是我收到一个错误:
Connection string
连接字符串
<add name="ApplicationODBCDefault" connectionString="Driver={PostgreSQL};Server=127.0.0.1;Port=5432;Database=dbname;Uid=name;Pwd=password;"/>
Error:
错误:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I have downloaded and installed both the 32 bit and 64 bit drivers for PostgreSQL ODBC from Hereand it still isn't working. What could be the issue here?
我已经从这里下载并安装了 PostgreSQL ODBC 的 32 位和 64 位驱动程序,但它仍然无法正常工作。这里可能有什么问题?
采纳答案by Micha? Niklas
Instead of {PostgreSQL}
use {PostgreSQL ANSI}
or {PostgreSQL UNICODE}
而不是{PostgreSQL}
使用{PostgreSQL ANSI}
或{PostgreSQL UNICODE}
Driver={PostgreSQL UNICODE};Server=127.0.0.1;Port=5432;Database=dbname;Uid=name;Pwd=password;
for more connection strings have a look at: http://www.connectionstrings.com/postgre-sql
有关更多连接字符串,请查看:http: //www.connectionstrings.com/postgre-sql
You can also configure DSN using ODBC Data Source Administrator and then use created DSN name in ConnectionString:
您还可以使用 ODBC 数据源管理器配置 DSN,然后在 ConnectionString 中使用创建的 DSN 名称:
DSN=dsn_name;Uid=name;Pwd=password;
回答by lexes
If you are using the 64 bits version of PostgreSQL, then you should use in the connection string:
如果您使用的是 64 位版本的 PostgreSQL,那么您应该在连接字符串中使用:
Driver={PostgreSQL UNICODE(x64)};Server=127.0.0.1; .......
驱动程序={PostgreSQL UNICODE(x64)};服务器=127.0.0.1;......