我想壓縮我的Microsoft Access 2010數據庫。我正在使用VS 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.ACE.OLEDB.12.0;Data Source=\C:\Forte\Fortedb.accdb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\C:\Forte\Compactdb.accdb")
'Original (not compacted database is deleted)
System.IO.File.Delete("C:\Program Files\VSoft\AppMiss\NewAppDB.mdb")
'Compacted database is renamed to the original databas's name.
Rename("C:\Forte\Compactdb.accdb", "C:\Forte\Fortedb.accdb")
'User notification
MsgBox("The database was compacted successfully")
End Sub
現在我得到的錯誤是
錯誤1無法複製文件「\ phipnasw01 \用戶臀圍$ \ cerns1 \我的文檔\ Visual Studio 2010的\項目\復地數據採集器\復Data Gatherer \ Example1.accdb「更改爲」bin \ Debug \ Example1.accdb「。無法找到文件'\ phipnasw01 \ users-hip $ \ cerns1 \ My Documents \ Visual Studio 2010 \ Projects \ Forte Data Gatherer \ Forte Data Gatherer \ Example1.accdb'。 Forte Data Gatherer
錯誤消息指的是與您的示例不同的文件和路徑。你會在哪一行發生異常? – Steve
這不是特定的行,它只是在Visual Studio底部的錯誤列表中。 –
你有你的accdb文件列在你的項目文件和它的屬性「複製到輸出目錄」設置爲「始終複製」? – Steve