Permission denied when try rename file after transfer data.(MoveFile) -
09-09-2008
, 09:23 AM
Hi,
My main objective of this DTS is to create an Access Database with
datestamp on the back of the filename. It will export data from SQL
query in to Access Database.
Image: http://img255.imageshack.us/img255/7...basenx7.th.jpg
Steps as shown:
1. Create date path : eg: C:/Desktop/20080909/
2. Check if the file exists in the folder, let say if test.mdb exist,
then will rename to backup any exsiting test_200809091000.mdb ( 1000
is time )
3. Create table Test inside (Step 5)
4. Create connection db
5. Transfer SQL Query into MDB
6. Access Database ( Path : C:/Desktop/20080909/test.mdb )
7. Rename test.mdb to test_20080909.mdb
It shows Permission denied in the bold line step 7. Why? Izit because
after i transfer data into Access. the file is still open??? Or any
other better method?
Step 7 ActiveX Code
Function Main()
Dim objFSO
Dim sFile
Dim sFileNewName
Set objFSO = CreateObject("Scripting.FileSystemObject")
sFile = DTSGlobalVariables("Path").Value &
DTSGlobalVariables("FolderDate").Value
sFileNewName = sFile & "\" &"Redemption_" & Year(Date) & Right("0" &
Month(Date), 2) & Right("0" & Day(Date), 2) & ".mdb"
sFile = sFile & "\" & "Redemption.mdb" objFSO.MoveFile sFile, sFileNewName
Set objFSO = Nothing
Main = DTSTaskExecResult_Success
End Function |