3 Replies - 1874 Views - Last Post: 27 November 2012 - 09:54 AM Rate Topic: -----

#1 dharshanamomaya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-November 12

permission denied problem while trying to take backup

Posted 27 November 2012 - 05:40 AM

this is what i have done till now


[/b]
Dim fso As New FileSystemObject
Private Sub Drive1_Change()
' The Drive property also returns the volume label, so trim it.
Dir1.Path = Left$(Drive1.Drive, 1) & ":\"
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub File1_click()
FileName = File1.Path
If Right$(FileName, 1) <> "\" Then FileName = FileName & "\"
FileName = FileName & File1.FileName
End Sub
Private Sub Command1_Click()
Dim Source, Destination As String

    'con.Close
    'fso = CreateObject("Scripting.filesystemobject")
    Source = "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\quiz.mdf"
    Destination = "C:\Users\USER\Desktop\Backup\" & Format(Date, "mmmm dd, yyyy") & " " & Format(Time, "h_mm_ss") & ".mdf"
    fso.CopyFile Source, Destination
   
    MsgBox " Backup!", vbInformation, ""
    'conn.Open
    
End Sub
Private Sub Command2_Click()
Dim Source, Destination As String
    
    Source = App.Path & "\Backup\" & Text1
    'conn.Close
    Destination = App.Path & "\Dbregistrar.mdb"
    
    FileCopy Source, Destination
    MsgBox "Recover", vbInformation, ""
    'conn.Open
    
End Sub
[b]


but when i try to run the code, an permission denied error is coming. please help me out..

Is This A Good Question/Topic? 0
  • +

Replies To: permission denied problem while trying to take backup

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: permission denied problem while trying to take backup

Posted 27 November 2012 - 07:58 AM

I'm assuming your error is on the actual CopyFile line and is most likely because the database is in use/locked by SQL Server (I'm making an assumption here based on your Source path).

To prove that, try stopping the SQL service and then see if you can copy the file. If so, then if this is a true backup, then maybe it's worth looking at the SQL Server itself and scheduling the backup to run from there?

I'm no DBA, so this is only a suggestion.
Was This Post Helpful? 0
  • +
  • -

#3 dharshanamomaya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-November 12

Re: permission denied problem while trying to take backup

Posted 27 November 2012 - 09:34 AM

thank you for the quick reply.. i have debugged the error. i just changed the autoclose property to true and then the backup code worked properly
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: permission denied problem while trying to take backup

Posted 27 November 2012 - 09:54 AM

Glad you got it sorted.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1