W
Wayne Wengert
I am using VB Express 2005 and in the code I want to compact the active
database. I am using the code below (I've left out the Try/Catch code for
clarity). I get an error on the File.Move that complains that the
file(DatabaseName) is in use by another application? Since I close the
connection, I don't understand this error?
==================== Code ===============
.....
myConn.Close()
CompactDB(myDBFilePath)
.....
Public Function CompactDB(ByVal DatabaseName As String)
Dim db As dao.DBEngine
Dim AppPath = System.AppDomain.CurrentDomain.BaseDirectory()
Dim sUFN As String
Dim sFN As String = System.IO.Path.GetFileNameWithoutExtension(DatabaseName)
sUFN = AppPath & "\" & sFN & Format(Now, "MMddyyyyHHmmss.mdb")
File.Move(DatabaseName, sUFN)
db = New dao.DBEngine()
db.CompactDatabase(sUFN, AppPath & "\" & sFN)
CompactDB = True
End Function
database. I am using the code below (I've left out the Try/Catch code for
clarity). I get an error on the File.Move that complains that the
file(DatabaseName) is in use by another application? Since I close the
connection, I don't understand this error?
==================== Code ===============
.....
myConn.Close()
CompactDB(myDBFilePath)
.....
Public Function CompactDB(ByVal DatabaseName As String)
Dim db As dao.DBEngine
Dim AppPath = System.AppDomain.CurrentDomain.BaseDirectory()
Dim sUFN As String
Dim sFN As String = System.IO.Path.GetFileNameWithoutExtension(DatabaseName)
sUFN = AppPath & "\" & sFN & Format(Now, "MMddyyyyHHmmss.mdb")
File.Move(DatabaseName, sUFN)
db = New dao.DBEngine()
db.CompactDatabase(sUFN, AppPath & "\" & sFN)
CompactDB = True
End Function