Compacting an Access database from ASP code
This source code can compact and repair your MS-Access database files. If you compact your access files regularly, it will work more faster and secure. Also you will save some hard disk space.
<%
oldFile = Server.MapPath("db.mdb")
newFile = Server.MapPath("bak.mdb")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& oldFile
strConnBak = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & newFile
Set objJRO = Server.CreateObject("JRO.JetEngine")
objJRO.CompactDatabase strConn, strConnBak
Set objJRO = Nothing
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(newFile) And objFSO.FileExists(oldFile) Then
objFSO.DeleteFile(oldFile)
objFSO.MoveFile newFile, oldFile
Response.Write "Compact and Repair was successful."
Else
Response.Write "Compact and Repair failed."
End If
Set objFSO = Nothing
%>
|
Comments:no comments submitted
Only members can write comments.Please,
login /
register to write comment.
Latest Posts