简体   繁体   中英

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

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

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 !

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!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM