<% 'Clean up Set rsCommon = Nothing adoCon.Close Set adoCon = Nothing
'Check to see if the user is using an access database If strDatabaseType <> "Access" Then
'Display message to sql server usres Response.Write "This page only works on Access but your Database Type is set to SQL Server" Response.End End If
'Dimension variables Dim objJetEngine 'Holds the jet database engine object Dim objFSO 'Holds the FSO object Dim strCompactDB 'Holds the destination of the compacted database
<p class="text"><b><span class="tblDataT"><font size="5">Compact and Repair Access Database</font></span></b><br /> <br /> <p class="tblDataT">Click the Below button to compact and repair the Webtime Access Data Base<br /></p> <%
'If this is a post back run the compact and repair If Request.Form("postBack") Then %> <table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="tblDataT"><ol><%
'Create an intence of the FSO object Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Back up the database objFSO.CopyFile strDbPathAndName, Replace(strDbPathAndName, ".mdb", "-backup.mdb", 1, -1, 1)
'Create an intence of the JET engine object Set objJetEngine = Server.CreateObject("JRO.JetEngine")
'Get the destination and name of the compacted database strCompactDB = Replace(strDbPathAndName, ".mdb", "-tmp.mdb", 1, -1, 1)
'Compact database objJetEngine.CompactDatabase strCon, "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & strCompactDB
'Display text that new compact db is created Response.Write(" <li class=""tblDataT"">New compacted database:-<br/><span class=""smText"">" & strCompactDB & "</span><br /><br /></li>")
'Release Jet object Set objJetEngine = Nothing
'Delete old database objFSO.DeleteFile strDbPathAndName
'Display text that that old db is deleted Response.Write(" <li class=""tblDataT"">Old uncompacted database deleted:-<br/><span class=""smText"">" & strDbPathAndName & "</span><br /><br /></li>")
'Rename temporary database to old name objFSO.MoveFile strCompactDB, strDbPathAndName
'Display text that that old db is deleted Response.Write(" <li class=""tblDataT"">Rename compacted database from:-<br/><span class=""smText"">" & strCompactDB & "</span><br />To:-<br /><span class=""smText"">" & strDbPathAndName & "</span><br /><br /></li>")
'Release FSO object Set objFSO = Nothing
Response.Write(" The Forums Access database is now compacted and repaired")
'Set the date time format to your own if you are getting a CDATE error 'Session.LCID = 1033
Dim adoCon 'Database Connection Variable Object Dim strCon 'Holds the string to connect to the db Dim rsCommon 'Database recordset Dim lngLoggedInUserID 'Holds the logginned in user ID Dim strUsername 'Holds the users username Dim strPassword 'Holds the usres password Dim strUserCode 'Holds the users ID code Dim strLoggedInUserCode 'Holds the loggin in user ID Dim strSQL 'Holds the SQL query Dim strSalt 'Holds salt values Dim strCode 'Holds the page code Dim strCode2 'Holds the page code Dim strDatabaseDateFunction 'Holds a different date function for Access or SQL server Dim strDatabaseType 'Holds the type of database used Dim strDbPathAndName 'Holds the path and name of the database Dim intGroupID 'Holds the group ID of the user
Comments
backup
use this code to back up you ms access database
file name compact_access_db.asp
<% Option Explicit %>
<!--#include file="common.asp" -->
<%
'Clean up
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing
'Check to see if the user is using an access database
If strDatabaseType <> "Access" Then
'Display message to sql server usres
Response.Write "This page only works on Access but your Database Type is set to SQL Server"
Response.End
End If
'Dimension variables
Dim objJetEngine 'Holds the jet database engine object
Dim objFSO 'Holds the FSO object
Dim strCompactDB 'Holds the destination of the compacted database
%>
<html>
<head>
<title>Compact and Repair Access Database</title>
<link href="../CSS/name.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#ffffff" text="BLACK">
<table border="0" width="750px" height="80" cellpadding="0" cellspacing="0">
<tr>
<td width="36" rowspan="2" height="76"> </td>
<td width="95%" valign="bottom" align="center" height="57">
<% =sBlank%>
<p class="text"><b><span class="tblDataT"><font size="5">Compact and Repair Access Database</font></span></b><br />
<br />
<p class="tblDataT">Click the Below button to compact and repair the Webtime Access
Data Base<br /></p>
<%
'If this is a post back run the compact and repair
If Request.Form("postBack") Then %>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="tblDataT"><ol><%
'Create an intence of the FSO object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Back up the database
objFSO.CopyFile strDbPathAndName, Replace(strDbPathAndName, ".mdb", "-backup.mdb", 1, -1, 1)
Response.Write(" <li class=""tblDataT"">Database backed up to:-<br/><span class=""smText"">" & Replace(strDbPathAndName, ".mdb", "-backup.mdb", 1, -1, 1) & "</span><br /><br /></li>")
'Create an intence of the JET engine object
Set objJetEngine = Server.CreateObject("JRO.JetEngine")
'Get the destination and name of the compacted database
strCompactDB = Replace(strDbPathAndName, ".mdb", "-tmp.mdb", 1, -1, 1)
'Compact database
objJetEngine.CompactDatabase strCon, "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & strCompactDB
'Display text that new compact db is created
Response.Write(" <li class=""tblDataT"">New compacted database:-<br/><span class=""smText"">" & strCompactDB & "</span><br /><br /></li>")
'Release Jet object
Set objJetEngine = Nothing
'Delete old database
objFSO.DeleteFile strDbPathAndName
'Display text that that old db is deleted
Response.Write(" <li class=""tblDataT"">Old uncompacted database deleted:-<br/><span class=""smText"">" & strDbPathAndName & "</span><br /><br /></li>")
'Rename temporary database to old name
objFSO.MoveFile strCompactDB, strDbPathAndName
'Display text that that old db is deleted
Response.Write(" <li class=""tblDataT"">Rename compacted database from:-<br/><span class=""smText"">" & strCompactDB & "</span><br />To:-<br /><span class=""smText"">" & strDbPathAndName & "</span><br /><br /></li>")
'Release FSO object
Set objFSO = Nothing
Response.Write(" The Forums Access database is now compacted and repaired")
%></ol></td>
</tr>
</table>
<%
Else
%>
<p class="text"> </p>
</div>
<form action="compact_access_db.asp" method="post" name="frmCompact" id="frmCompact">
<div align="center"><br />
<input name="postBack" type="hidden" id="postBack" value="true">
<input type="submit" name="Submit" value="Compact and Repair Database" style="background-color: #6699CC">
</div>
</form><%
End If
%>
<br />
</body>
the include file
common.asp
Server.ScriptTimeout = 90
'Set the date time format to your own if you are getting a CDATE error
'Session.LCID = 1033
Dim adoCon 'Database Connection Variable Object
Dim strCon 'Holds the string to connect to the db
Dim rsCommon 'Database recordset
Dim lngLoggedInUserID 'Holds the logginned in user ID
Dim strUsername 'Holds the users username
Dim strPassword 'Holds the usres password
Dim strUserCode 'Holds the users ID code
Dim strLoggedInUserCode 'Holds the loggin in user ID
Dim strSQL 'Holds the SQL query
Dim strSalt 'Holds salt values
Dim strCode 'Holds the page code
Dim strCode2 'Holds the page code
Dim strDatabaseDateFunction 'Holds a different date function for Access or SQL server
Dim strDatabaseType 'Holds the type of database used
Dim strDbPathAndName 'Holds the path and name of the database
Dim intGroupID 'Holds the group ID of the user
'Intialise variables
Const strVersion = "7.9"
strSalt = "5CB237B1D85"
Const strCodeField = "L_code"
lngLoggedInUserID = 0
intGroupID = 0
Const blnMassMailier = True
'Database Type
strDatabaseType = "Access"
Const strDbTable = "tbl"
Const strDbProc = "wwfSp"
onst strCookieName = "WWF"
Const blnEncryptedPasswords = true
'Create database connection
'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'If this is access set the access driver
If strDatabaseType = "Access" Then
'--------------------- Set the path and name of the database --------------------------------------------------------------------------------
'Virtual path to database
strDbPathAndName = Server.MapPath("name.mdb") 'This is the path of the database from this files location on the server
You must me logged in to write a comment.