Discussion Locked

Active Server Page Toolbar Execution fro

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am interested in having ASP code to go from
Microsoft Access to Click on Tools, Click on
Database Utilities and Click on Compact Database
and then return. The code can be in a Microsoft
Access module or macro.

Thank you.

1 reply

by sachinp78

Here is the code:

<%
Const Jet_Conn_Partial = "Provider=Microsoft.Jet.OLEDB.4.0; Data source="

Private Sub dbCompact(strDBFileName)

SourceConn = Jet_Conn_Partial & strFolder & strDatabase
DestConn = Jet_Conn_Partial & strFolder & "Temp" & strDatabase
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oJetEngine = Server.CreateObject("JRO.JetEngine")
With oFSO
if Not .FileExists(strFolder & strDatabase) Then
Response.Write ("Not Found: " & strFolder & strDatabase)
Stop
Else
if .FileExists(strFolder & "Temp" & strDatabase) Then
Response.Write ("Something went wrong last time " _
& "Deleting old database... Please try again")
.DeleteFile (strFolder & "Temp" & strDatabase)
End if
End if
End With
With oJetEngine
.CompactDatabase SourceConn, DestConn
End With
oFSO.DeleteFile strFolder & strDatabase
oFSO.MoveFile strFolder & "Temp" _
& strDatabase, strFolder& strDatabase
Set oFSO = Nothing
Set oJetEngine = Nothing
End Sub
Private Sub dbList()
Dim oFolders
Set oFolders = Server.CreateObject("Scripting.FileSystemObject")
Response.Write ("")
For Each Item In oFolders.GetFolder(strFolder).Files
if LCase(Right(Item, 4)) = ".mdb" Then
Response.Write ("" & Replace(Item, strFolder, "") & "")
End if Next
Response.Write ("")
Set oFolders = Nothing
End Sub
%>

This discussion is closed to new replies.