Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2008
    Posts
    8

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

    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
    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

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    this is likely a server permissions issue for the process that is running this code. if this is a sql agent job, it would be the account the sql agent runs on.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Sep 2008
    Posts
    8
    I need to manually run this DTS Package. If I manually run STEP 7 only, it successfully . But if i run the whole package it fail due to permission denied.

    I think is because when it transfer data into Access, the database file is still open.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •