Compress access database





1
Date Submitted Thu. Apr. 30th, 2009 7:09 AM
Revision 1 of 1
Beginner johnyM
Tags VB.NET
Comments 0 comments
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

Johny Meyssen

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Scripter elsevero

Votes Down