我正在将VB6数据库应用程序迁移到VB 2015。
注意:第一个问题是缺少ACE.OLEDB.12.0提供程序。安装“可再发行的Access数据库引擎2010可再发行引擎”解决了我的32位和64位计算机上的问题。我正在3台计算机上测试此代码 - Win7,Win10和Win 10 64bit。
然而,接下来是“......可安装的ISAM”问题。显然已经建立了连接,但程序阻塞了Open()命令 - 给出了ISAM错误。以下是简单的测试代码:
Imports System.Data.OleDb
Public Class frmTitles
Dim BooksConnection As OleDbConnection
Private Sub frmTitles_Load (sender As Object, e As EventArgs) Handles Me.Load
'connect to books database
BooksConnection = New leDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; DataSource = d:\VB-Data\BooksDB.accdb")
'open the connection
BooksConnection.Open() ‘ Blocks here
'display state
lblState.Text = BooksConnection.State.ToString
'close the connection
BooksConnection. Close()
'display state
lblState.Text += BooksConnection.State.ToString
'dispose of the connection object
BooksConnection.Dispose()
End Sub
End Class
请注意,尝试连接.mdb数据库会产生相同的错误:
BooksConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource = d:\VB-Data\Books.mdb")