|
|
|
Compress access database
1
Code to compress a Access database on the serve
Dim filename As String = Server.MapPath("~/App_Data/mydatabase.mdb")
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filename
Dim objJRO As Object = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("JRO.JetEngine"))
Dim oParams As Object() = New Object() {connectionString, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filename & ".tmp ;Jet OLEDB:Engine Type=5"}
objJRO.GetType().InvokeMember("CompactDatabase", System.Reflection.BindingFlags.InvokeMethod, Nothing, objJRO, oParams)
System.IO.File.Delete(filename)
System.IO.File.Move(filename & ".tmp", filename)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objJRO)
objJRO = Nothing
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filename
Dim objJRO As Object = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("JRO.JetEngine"))
Dim oParams As Object() = New Object() {connectionString, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filename & ".tmp ;Jet OLEDB:Engine Type=5"}
objJRO.GetType().InvokeMember("CompactDatabase", System.Reflection.BindingFlags.InvokeMethod, Nothing, objJRO, oParams)
System.IO.File.Delete(filename)
System.IO.File.Move(filename & ".tmp", filename)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objJRO)
objJRO = Nothing




There are currently no comments for this snippet.