简体   繁体   English

Postgresql odbc驱动程序错误c#[IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称

[英]Postgresql odbc driver error c# [IM002] [Microsoft][ODBC Driver Manager] Data source name not found

I am setting up an database application to be database agnostic, and when testing with postgresql I get the standard dsn error: 我正在将数据库应用程序设置为与数据库无关,并且在使用PostgreSQL测试时,我收到标准的dsn错误:

[IM002] [Microsoft][ODBC Driver Manager] Data source name not found [IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称

I usually use SQL server and MySQL so I'm new to postgres, I tried the standard recommended Connection string: 我通常使用SQL Server和MySQL,因此对Postgres并不陌生,我尝试了推荐的标准连接字符串:

"Driver = {PostgreSQL}; Server = localhost; Database = postgres; Port = 5432; Uid = postgres; Pwd = XXXXXX;"

I also tried the name of the odbc driver that I installed after installing postrgesql: 我还尝试了在安装postrgesql之后安装的odbc驱动程序的名称:

"Driver = {PostgreSQL ODBC Driver(UNICODE)}; Server = localhost; Database = postgres; Port = 5432; Uid = postgres; Pwd = XXXXXX;"

Setting up a DSN in odbc manager also works perfectly using the unicode driver, so I cant understand why i cant connect in my application, is there an error in the driver name that i am using in the connection string? 在odbc管理器中设置DSN也可以使用unicode驱动程序完美地工作,因此我无法理解为什么我无法在应用程序中进行连接,我在连接字符串中使用的驱动程序名称是否存在错误?

Your error message looks very strange. 您的错误消息看起来很奇怪。 It tells about DSN not found. 它说明未找到DSN。 Are you sure you use connect string with Driver=... ? 您确定使用Driver=...连接字符串吗?

You can use ODBC connect string in several forms. 您可以以多种形式使用ODBC连接字符串。 At first you have created DSN, so you can use it: 首先,您已经创建了DSN,因此可以使用它:

DSN=mn_test; Uid=postgres; Pwd=postgres;

Then you can use other form of connect string: 然后,您可以使用其他形式的连接字符串:

Driver={PostgreSQL UNICODE};Server=127.0.0.1; Port=5493; Database=mn_test; Uid=postgres; Pwd=postgres;

Both work on my old 32 bit Windows environment. 两者都可以在我的旧32位Windows环境下工作。 I test them with simple Python script (I use ActiveState Python in which there is simple odbc module): 我用简单的Python脚本测试它们(我使用ActiveState Python,其中有简单的odbc模块):

import odbc

def test_odbc(connect_string):
    print(connect_string)
    db = odbc.odbc(connect_string)
    c = db.cursor()
    rs = c.execute("SELECT version()")
    for txt in c.fetchall():
        print('%s' % (txt[0]))
    print('-----')

test_odbc('Driver={PostgreSQL UNICODE};Server=127.0.0.1; Port=5493; Database=mn_test; Uid=postgres; Pwd=postgres;')
test_odbc('DSN=mn_test; Uid=postgres; Pwd=postgres;')

When you created the DSN, did you create it with the correct odbcad tool? 创建DSN时,是否使用正确的odbcad工具创建了DSN? With the 64bit version found in C:\\Windows\\System32 if your application is 64bit and with the 32bit version found in C:\\Windows\\SysWOW64 if your application is 32bit? 如果您的应用程序是64位,则在C:\\Windows\\System32找到64位版本;如果您的应用程序是32位,则在C:\\Windows\\SysWOW64找到32位版本?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从C#通过ODBC访问Sql Server:错误[IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序 - Access to Sql Server via ODBC from C# : ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 附加信息:错误[IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序 - Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 通过C#程序访问MySQL-错误[IM002]找不到数据源名称,并且未指定默认驱动程序 - Accessing MySQL via C# program - ERROR [IM002] Data source name not found and no default driver specified 我的SQL连接错误Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序 - My Sql Connection error Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified MySQL ODBC-IM002 - MySQL ODBC - IM002 部署后获取[ODBC Driver Manager]数据源名称未找到错误 - Getting [ODBC Driver Manager] Data source name not found error after deployment ODBC错误-找不到数据源名称,并且未指定默认驱动程序 - ODBC Error - Data source name not found and no default driver specified 错误找不到数据源名称,并且在ADO.NET中没有使用Odbc指定默认驱动程序 - Error Data source name not found and no default driver specified with Odbc in ADO.NET 具有C#中ODBC驱动程序的PostgreSQL连接字符串,不支持关键字:驱动程序 - PostgreSQL Connection String with ODBC driver in C#, Keyword not supported: driver 在 C# 中创建自定义 ODBC/OLE 驱动程序 - Creating a custom ODBC / OLE driver in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM