我想压缩我的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