Vb.net 压缩数据库错误消息

Vb.net 压缩数据库错误消息,vb.net,ms-access-2010,Vb.net,Ms Access 2010,当我试图压缩Access 2010数据库(无密码)时,收到错误消息Class Not Registered我正在使用Visual Studio 2010,我不知道这个问题是什么。以下是我正在使用的代码: Private Sub Compactdb() Dim JRO As JRO.JetEngine JRO = New JRO.JetEngine 'The first source is the original, the second is the compact

当我试图压缩Access 2010数据库(无密码)时,收到错误消息Class Not Registered我正在使用Visual Studio 2010,我不知道这个问题是什么。以下是我正在使用的代码:

Private Sub Compactdb()

    Dim JRO As JRO.JetEngine
    JRO = New JRO.JetEngine


    'The first source is the original, the second is the compacted database under an other name.
    JRO.CompactDatabase("Provider=Microsoft.Jet.OLEDB.5.0;Data Source=C:\Forte\Ex.mdb; Jet OLEDB:Engine Type=5", "Provider=Microsoft.Jet.OLEDB.5.0;Data Source=C:\Forte\Temp.mdb; JetOLEDB:Engine Type=5")


    'Original (not compacted database is deleted)
    System.IO.File.Delete("C:\Forte\Ex.mdb")


    'Compacted database is renamed to the original databas's neme. 
    Rename("C:\Forte\Temp.mdb", "C:\Forte\Ex.mdb")


    'User notification
    MsgBox("The database was compacted successfully")

End Sub
如果我将Jet.OLEDB.5.0更改为4.0,我会收到另一条错误消息无法识别的数据库格式

    Try
        Dim ParentCNN As String
        Dim CloneCNN As String
        Dim JrO As New JRO.JetEngine

        ParentCNN = "PROVIDER = MICROSOFT.ACE.OLEDB.12.0;DATA SOURCE = C:\Forte\Fortedb.accdb;JET OLEDB:DATABASE PASSWORD = 21061975;"
        CloneCNN = "PROVIDER = MICROSOFT.ACE.OLEDB.12.0;DATA SOURCE = C:\Forte\Temp.accdb;JET OLEDB:DATABASE PASSWORD = 21061975;Jet OLEDB:Engine Type=5"
        'If cnnMDE.State = ConnectionState.Open Then
        '    cnnMDE.Close()
        'End If
        JrO.CompactDatabase(ParentCNN, CloneCNN)
        If System.IO.File.Exists("C:\Forte\Temp.accdb") Then
            System.IO.File.Delete("C:\Forte\Fortedb.accdb")
            Rename("C:\Forte\Temp.accdb", "C:\Forte\Fortedb.accdb")
        End If
    Catch ex As Exception
        MainTextBox.AppendText(Environment.NewLine & "Database Compression Failure :" & vbCr & ex.Message)
    End Try