Access to Sql Server via ODBC from C# : ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

眉间皱痕 提交于 2019-12-24 09:49:36

问题


I have a System DSN configured and test ok :

Microsoft SQL Server Native Client Version 10.00.2531

Data Source Name: xxx Data Source

Description: xxx Server: SERVER\SHARE

Use Integrated Security: Yes Database:

yyy Language: (Default) Data

Encryption: No Trust Server

Certificate: No Multiple Active Result

Sets(MARS): No Mirror Server:

Translate Character Data: Yes Log Long

Running Queries: No Log Driver

Statistics: No Use Regional Settings:

No Use ANSI Quoted Identifiers: Yes

Use ANSI Null, Paddings and Warnings:

Yes

I work on a windows 7 64 bits. The code in running in x86 mode.

In Excel, I can connect only to User DSN, the System DSN does not appear. I tried also a use DSN, It works in excel but not in c#

I changed the permissions for the ODBC to everyone in regedit.

I use this connectionstring in the c# code : Data Source=xxx;Initial Catalog=yyy;Integrated Security=SSPI;

I have this error : ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Any idea ?

Thanks in advance


回答1:


I achieved to connect to the database without ODBC with that connection string:

 Driver={SQL Server Native Client 10.0};Server=xxx;Database=zzz;Trusted_Connection=yes;

Thanks !




回答2:


he initial problem posted here is most likely due to the fact that a 64bit ODBC Data Source has been created (using the ODBC Administrator via the Control Panel) and the app is only 32bit.

Put another way --

32bit apps require 32bit ODBC Drivers and 32bit DSNs (C:\Windows\SysWOW64\odbcad32.exe)

64bit apps require 64bit ODBC Drivers and 64bit DSNs (C:\Windows\System32\odbcad32.exe)

32 and 64bit components CANNOT be interchanged here!!



来源:https://stackoverflow.com/questions/3438788/access-to-sql-server-via-odbc-from-c-sharp-error-im002-microsoftodbc-driv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!