Fordraiders
asked on
Compact Repair: revision for open database
vb.net 2003
access 2003
What I have:
Public Sub CompactAccessDBEnd(ByVal strConnectionString As String, ByVal strMDBFilename As String)
Dim oParams As Object()
Dim strMe As String
If System.IO.File.Exists("C:\ PROGRAM FILES\DM\CAT.MDB") Then
strMe = FileLen("C:\PROGRAM FILES\DM\CAT.MDB")
Dim jro As JRO.JetEngine
jro = New JRO.JetEngine
jro.CompactDatabase("Provi der=Micros oft.Jet.OL EDB.4.0;Da ta Source=C:\Program Files\dm\Cat.mdb", _
"Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=C:\Program Files\dm\Cat2.mdb;Jet OLEDB:Engine Type=5")
System.IO.File.Delete(strM DBFilename )
System.IO.File.Move("C:\Pr ogram Files\dm\Cat2.mdb", strMDBFilename)
' Clean up (Just in case)
System.Runtime.InteropServ ices.Marsh al.Release ComObject( jro)
jro = Nothing
' End If
End If
End Sub
What I need:
Sometimes the database cat.mdb may be open...
If it is close it first then run the routine...
Thanks
fordraiders
access 2003
What I have:
Public Sub CompactAccessDBEnd(ByVal strConnectionString As String, ByVal strMDBFilename As String)
Dim oParams As Object()
Dim strMe As String
If System.IO.File.Exists("C:\
strMe = FileLen("C:\PROGRAM FILES\DM\CAT.MDB")
Dim jro As JRO.JetEngine
jro = New JRO.JetEngine
jro.CompactDatabase("Provi
"Provider=Microsoft.Jet.OL
System.IO.File.Delete(strM
System.IO.File.Move("C:\Pr
' Clean up (Just in case)
System.Runtime.InteropServ
jro = Nothing
' End If
End If
End Sub
What I need:
Sometimes the database cat.mdb may be open...
If it is close it first then run the routine...
Thanks
fordraiders
The downside to using access for this kind of thing is that if the database is in use by another application (or another instance of your application), you're at the mercy of that application.
ASKER
is there a way to close the database if it is open ?
Or is there an error trap ?
Or is there an error trap ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.