|
tanx tanx tanx ...... the final way found the two I think this two code Should Work
http://www.dotnetindex.com/articles/59/?SESSION=607828084&REF=http%3A%2F%2Fwww%2Ehotscripts%2Ecom%2FDetailed%2F30553%2Ehtml - http://www.dotnetindex.com/articles/59/?SESSION=607828084&am p;REF=http%3A%2F%2Fwww%2Ehotscripts%2Ecom%2FDetailed%2F30553 %2Ehtml
<% 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 "<font size=""+2"" color=""crimson"">Compact and Repair was successful.</font>" Else Response.Write "<font size=""+2"" color=""crimson"">Compact and Repair failed.</font>" End If
Set objFSO = Nothing %> ------------------------------------------------------------ --
at : http://dmxzone.com/ShowDetail.asp?NewsId=6398 - http://dmxzone.com/ShowDetail.asp?NewsId=6398
<% Option Explicit %> <% '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 Dim strDbPathAndName Dim strCon
strDbPathAndName = Server.MapPath("database.mdb") strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strDbPathAndName %> <html> <head> <title>Compact And Repair Access Database</title> </head> <body> <h2>Compact And Repair Access Database</h2> <br /> <% '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> <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>Database backed up to:-<br/><span>" & 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>New compacted database:-<br/><span>" & 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>Old uncompacted database deleted:-<br/><span>" & 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>Rename compacted database from:-<br/><span>" & strCompactDB & "</span><br />To:-<br /><span>" & strDbPathAndName & "</span><br /><br /></li>")
'Release FSO object Set objFSO = Nothing
Response.Write(" The Access database is now compacted and repaired")
%></ol></td> </tr> </table> <% Else
%> <p
------------- Sincerely
--------------------
http://www.TacPlusPlus.com - PowerFull Scripts For NTTacPlus
|