%
'==============================================================
' TableEditoR 0.81 Beta
' http://www.2enetworx.com/dev/projects/tableeditor.asp
'--------------------------------------------------------------
' File: te_compactdb.asp
' Description: Compacts an Access Mdb file
' Initiated By Hakan Eskici on Nov 01, 2000
'--------------------------------------------------------------
' Copyright (c) 2002, 2eNetWorX/dev.
'
' TableEditoR is distributed with General Public License.
' Any derivatives of this software must remain OpenSource and
' must be distributed at no charge.
' (See license.txt for additional information)
'
' See Credits.txt for the list of contributors.
'
' Change Log:
'--------------------------------------------------------------
' # April 18, 2002 by Rami Kattan
' Temporary files are in the same folder as the database
' as some ISP doesn't allow write to normal html folders
' # May 21, 2002 by Rami Kattan
' Fixes few bugs, when filename has ; for password
' # May 30, 2002 by Rami Kattan
' Backup now makes a copy of the original file itself, not
' a compacted version
'==============================================================
bOnlyBackup = (request.querystring("onlybackup") = "true")
%>
| Home » Connections » <% if bOnlyBackup then response.write "Backup" else response.write "Compact" %> Database | <% if bProtected then response.write session("teFullName") response.write " (logout)" end if %> |
<%
lConnID = request("cid")
on error resume next
sub ShowForm
%>
<% if not bOnlyBackup Then %>
The original database "<%=sFileFrom%>" will be compacted.
After compacting, the original file will be renamed to ".(date/time).bak" extension as a backup.
During the compact process, a ".temp.mdb" file will be created, and after the compact is successful, it will be deleted.
Compacting may take some time depending on your database size. The changes made to the database during the compact will not be saved.
<% else %>
The original database "<%=sFileFrom%>" will be backed-up.
The backup file will have the name with ".(date/time).bak" extension as a backup.
Backing up may take some time depending on your database size. The changes made to the database during the backup will not be saved.
<% end if %>
<% If not bOnlyBackup Then %> Are you sure that you want to compact the database? <% Else %> Are you sure that you want to backup the database? <% End If %>
Yes ">No <% end sub ShortFileName = arrDBs(lConnID) sFileFromParts = split(ShortFileName, ";") ShortFileName = sFileFromParts(0) Sub RenameFile(sFrom, sTo) Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") sDateTimeStamp = "." & year(now) & LeadingZero(month(now),2) & LeadingZero(day(now),2) & "-" & LeadingZero(hour(now),2) & LeadingZero(minute(now),2) & LeadingZero(second(now),2) If not bOnlyBackup Then fso.MoveFile sTo, Server.MapPath(ShortFileName & sDateTimeStamp & ".bak") fso.MoveFile sFrom, sTo Else fso.CopyFile sTo, sTo & sDateTimeStamp & ".bak" End If End Sub sFileFrom = Server.MapPath(ShortFileName) sFileTo = left(sFileFrom, InStr(sFileFrom, ".mdb")-1) & ".temp.mdb" sConnFrom = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & sFileFrom sConnTo = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & sFileTo if request("sure")<>"" then if bTableEdit then If not bOnlyBackup Then set jro = server.createobject("jro.JetEngine") jro.CompactDatabase sConnFrom, sConnTo if err <> 0 then bError = True response.write "Error: