Print Page | Close Window

backup & compact access db wid asp script

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14242
Printed Date: 30 March 2026 at 11:43am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: backup & compact access db wid asp script
Posted By: riya_singtel
Subject: backup & compact access db wid asp script
Date Posted: 14 March 2005 at 10:17pm
I am writing a code in asp using vb script. Have to backup and compact my access database. Can someone help me with the right code since I have absolutely no idea how to do it.
Thanks a ton



Replies:
Posted By: dj air
Date Posted: 15 March 2005 at 6:37am
to compact the database you can have a look at the forums built in one.

with regards to the back up feature.. i had required a simular feature what i did was

use FSO to make a copy of the database (was a file in my case but .mdb also works as i tested it).

to prevent erros etc i had copied the database on the webserver within a folder that is just made with the folder name being the date and time of creation.

one place to look for FSO is www.devguru.com

below is the code that creates a folder then  copies the file.


Set filesys = CreateObject("Scripting.FileSystemObject")

' check if the file exists
If filesys.FileExists(strAttachment) Then

set filetxt = filesys.GetFile(strAttachment)

StrDateAndTime = DateAdd("h",+0,NOW())

strTempPath = Day(StrDateAndTime) & "-" & Month(StrDateAndTime) & "-" & Year(StrDateAndTime) & "_" & Hour(StrDateAndTime) & "-" & Minute(StrDateAndTime) & "-" & Second(StrDateAndTime)


If Not filesys.FolderExists(strBackupPath & strTempPath) Then

   Set newfolder = filesys.CreateFolder(strBackupPath & strTempPath)

 
    filesys.CopyFile "path to file to back up", strBackupPath & strTempPath & "\"

 Set filesys = NOTHING
 


End If



replace strAttachment with the path to the .mdb file


Posted By: riya_singtel
Date Posted: 16 March 2005 at 12:27am
ThanksSmile



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net