dbTalk Databases Forums  

Permission denied when try rename file after transfer data.(MoveFile)

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Permission denied when try rename file after transfer data.(MoveFile) in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cyclone9
 
Posts: n/a

Default 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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.