vb.net Windows XP 上的错误 [IM002] [Microsoft][ODBC 驱动程序管理器]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18081147/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:33:42  来源:igfitidea点击:

ERROR [IM002] [Microsoft][ODBC Driver Manager] on Windows XP

vb.netx86windows-xpodbc

提问by jlaverde

I've made a VB.NET program that accesses some databases via ODBC. On the Windows 7 machine it works fine. On the Windows XP machine it installs, but when it open the application, this error happens. I developed this on Visual Studio 2012, both Windows 7 and Windows XP are x86, and both have the same System DSN's I'm trying to access. I've looked everywhere, but nothing specific to my problem. Any ideas? Thanks in advance!

我制作了一个通过 ODBC 访问一些数据库的 VB.NET 程序。在 Windows 7 机器上它工作正常。在它安装的 Windows XP 机器上,但当它打开应用程序时,会发生此错误。我在 Visual Studio 2012 上开发了这个,Windows 7 和 Windows XP 都是 x86,并且都具有我试图访问的相同系统 DSN。我到处找,但没有针对我的问题。有任何想法吗?提前致谢!

************** Exception Text **************
System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
   at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
   at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
   at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
   at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at CRManager.DataSet3TableAdapters.PartitionsSetTableAdapter.Fill(PartitionsSetDataTable dataTable)
   at CRManager.Form1.Form1_Load(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3649 (GDR.050727-3600)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Crystal Reports Manager
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Documents%20and%20Settings/jose.laverde/Local%20Settings/Apps/2.0/BOZHZTXY.AG4/CEDJGE66.BYJ/crys..tion_d4261ff73e300d69_0001.0001_e75947b0658a5fbd/Crystal%20Reports%20Manager.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3644 (GDR.050727-3600)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3645 (GDR.050727-3600)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3644 (GDR.050727-3600)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
Microsoft.VisualBasic.PowerPacks.Vs
    Assembly Version: 10.0.0.0
    Win32 Version: 11.0.50727.1
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic.PowerPacks.Vs/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.PowerPacks.Vs.dll
----------------------------------------
CrystalDecisions.Windows.Forms
    Assembly Version: 13.0.2000.0
    Win32 Version: 13.0.5.891
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Windows.Forms/13.0.2000.0__692fbea5521e1304/CrystalDecisions.Windows.Forms.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3650 (GDR.050727-3600)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
CrystalDecisions.Shared
    Assembly Version: 13.0.2000.0
    Win32 Version: 13.0.5.891
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Shared/13.0.2000.0__692fbea5521e1304/CrystalDecisions.Shared.dll
----------------------------------------
CrystalDecisions.ReportSource
    Assembly Version: 13.0.2000.0
    Win32 Version: 13.0.5.891
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportSource/13.0.2000.0__692fbea5521e1304/CrystalDecisions.ReportSource.dll
----------------------------------------
log4net
    Assembly Version: 1.2.10.0
    Win32 Version: 1.2.10.0
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/log4net/1.2.10.0__692fbea5521e1304/log4net.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3650 (GDR.050727-3600)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Web
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3648 (GDR.050727-3600)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
System.Data.DataSetExtensions
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.1 built by: SP
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Data.DataSetExtensions/3.5.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
----------------------------------------
System.Core
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.1 built by: SP
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------

采纳答案by FrankPl

The error message clearly states that your program does not find the DSN. Check that the bitness of the DSNs is correct. See http://support.microsoft.com/kb/942976for a description of some of the 64bit/32bit confusion.

该错误消息明确指出您的程序未找到 DSN。检查 DSN 的位数是否正确。有关某些 64 位/32 位混淆的说明,请参阅http://support.microsoft.com/kb/942976

回答by user2696636

Got the same problem. Had 1 VB proj on Windows 7 64 bit that worked fine. Started another project, copied the code over I needed and it failed saying couldn't find DSN. Having read Frank's comment, I went into Configuration Manager in VS 2010 and added a new "Active Solution Platform" of "Any CPU" and reran my project and all worked fine. My project was now 64 bit like the other project that worked.

遇到了同样的问题。在 Windows 7 64 位上有 1 个 VB 项目,运行良好。开始另一个项目,复制我需要的代码,但失败说找不到 DSN。阅读了弗兰克的评论后,我进入了 VS 2010 中的配置管理器,并添加了一个新的“任何 CPU”的“活动解决方案平台”,然后重新运行我的项目,一切正常。我的项目现在是 64 位,就像另一个有效的项目一样。

Kristian

克里斯蒂安

回答by user3576362

Thank you for this post, it solved my problem, though in my case, I had a VB project that worked fine on a SQLExpress database but gave me the above error when I tried to change the connection string to an Access database. But on another project, I connected to an Access database just fine. The 'Any CPU' was set and I changed that to 'x86' and then it worked for me.

感谢您的这篇文章,它解决了我的问题,尽管在我的情况下,我有一个 VB 项目在 SQLExpress 数据库上运行良好,但是当我尝试将连接字符串更改为 Access 数据库时出现上述错误。但在另一个项目中,我连接到 Access 数据库就好了。设置了“任何 CPU”,我将其更改为“x86”,然后它对我有用。