我有一个 VB.NET WinForm 应用程序,其中打开了与 MS Access 2002 数据库的 OLEDB 连接,如下所示:
Private Function MakeNewConnection(FullPath) As OleDbConnection
Dim Conn As OleDbConnection = New OleDbConnection()
Try
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + FullPath
Conn.Open()
Catch ex As Exception
Throw ex
End Try
Return Conn
End Function
虽然这通常可以正常工作,但它偶尔会在 Windows XP 32 位计算机 (SP3) 上生成错误。这是零星的,因为有时它工作得很好,有时它只是抛出一个错误!有两种类型的消息:未指定的错误或“Microsoft.Jet.OLEDB.4.0”提供程序未在本地计算机上注册。您将在本文末尾找到异常的堆栈跟踪。
我已经做了很多搜索。“提供者”错误主要与 64 位窗口有关。就我而言,它是一个 32 位系统!
任何想法?
详细错误:
Error message: Unspecified error
Stack trace:
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.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.OleDb.OleDbConnection.Open()
at QueryAgent.MakeNewConnection()
Error message: the 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine
Stack trace: at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.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.OleDb.OleDbConnection.Open()
at QueryAgent.MakeNewConnection()