Jet Engine无法识别的数据库格式

时间:2013-06-26 22:15:35

标签: vb.net ms-access-2010

我正在尝试使用vb.net压缩我的数据库并且我不断收到错误消息

  

无法识别的数据库格式'C:\ Forte \ Fortedb.accdb'。

我环顾四周,找不到任何可以帮助我的东西。这是我的代码

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 another name.
    JRO.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Forte\Fortedb.accdb;", "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Forte\Compactdb.accdb;")

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

    'Compacted database is renamed to the original database's name. 
    Rename("C:\Forte\fortedb.accdb", "C:\forte\Compactdb.accdb")

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

End Sub

2 个答案:

答案 0 :(得分:1)

参考http://www.connectionstrings.com/access-2007

您可以将conn字符串更改为

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Forte\Compactdb.accdb;Jet OLEDB:Database Password=MyDbPassword;

答案 1 :(得分:0)

其中之一应该起作用

provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\random\myAccess2007file.accdb; Persist Security Info=False;

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\random\myAccess2007file.accdb; Persist Security Info=False;