Try this (including the ISO date function ):
Dim pstrSourceFilePath
Dim pstrTargetFilePath
pstrSourceFilePath = Server.MapPath("../DB/Live.mdb")
pstrTargetFilePath = Server.MapPath("../Admin/Downloads/" & IsoDate(Now()) & "NewLive.mdb"
Dim objJetEngine
Set objJetEngine = Server.CreateObject("JRO.JetEngine")
objJetEngine.CompactDatabase _
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" _
& pstrSourceFilePath & ";",_
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" _
& pstrTargetFilePath & ";"
Set objJetEngine = Nothing
Function IsoDate(dteDate)
If IsDate(dteDate) = True Then
DIM dteDay, dteMonth, dteYear
dteDay = Day(dteDate)
dteMonth = Month(dteDate)
dteYear = Year(dteDate)
IsoDate = dteYear & _
"-" & Right(CStr(dteMonth + 100),2) & _
"-" & Right(CStr(dteDay + 100),2)
Else
IsoDate = Null
End If
End Function
Server.MapPath doesn't have to have a path that resolves - it merely changes the first part of *any*
path to take account of the location of the website root.
Chris.
Hi
The current scrip is:
Dim objJetEngine
Set objJetEngine = Server.CreateObject("JRO.JetEngine")
objJetEngine.CompactDatabase _
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" _
& Server.MapPath("../DB/Live.mdb") & ";",_
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" _
& Server.MapPath("../Admin/Downloads/NewLive.mdb") & ";"
Set objJetEngine = Nothing
I would like to change so that I can put a date before the file name eg:
myfilename = Date() &"NewLive.mdb"
myfilename = Replace(myfilename, "/", "-")