DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: Kill function resulting in Run-time error '70' Permission denied

  1. #1
    Join Date
    Feb 2008
    Posts
    52

    Kill function resulting in Run-time error '70' Permission denied

    Hi

    I'm running a routine which creates an Access 2000 database from an older database and then finally kills the original database.

    This process is run on three different databases but when it gets to a particular database it throws the above runtime error

    Here is the code

    Code:
    Public Sub CreateNewDataBase(databasefrom As String, UsePassword As Boolean, Optional Password As String)
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim rstTo As DAO.Recordset
    Dim ToDataBase As DAO.Database
    Dim i As Integer
    Dim j As Integer
    
    If (UsePassword = True) Then
        Set db = OpenDatabase(databasefrom, True, _
             False, ";pwd=" & Password)
        db.newPassword Password, ""
    Else
        Set db = OpenDatabase(databasefrom, True, False)
    End If
    
    DBEngine.CreateDatabase Replace(databasefrom, ".mdb", "temp.mdb"), dbLangGeneral, dbVersion40
    
    Set ToDataBase = OpenDatabase(Replace(databasefrom, ".mdb", "temp.mdb"), True, False)
    
    For i = 0 To db.TableDefs.Count - 1
        If (Left(db.TableDefs(i).name, 4) <> "MSys") Then
            copyTable db, ToDataBase, db.TableDefs(i).name, db.TableDefs(i).name
        End If
    Next i
    
    For i = 0 To db.QueryDefs.Count - 1
        Dim TblQuery As DAO.QueryDef
        ToDataBase.CreateQueryDef db.QueryDefs(i).name, db.QueryDefs(i).sql
    Next i
    
    For i = 0 To db.TableDefs.Count - 1
        If (Left(db.TableDefs(i).name, 4) <> "MSys") Then
            Set rst = db.OpenRecordset("SELECT * FROM [" & db.TableDefs(i).name & "]")
            Set rstTo = ToDataBase.OpenRecordset(db.TableDefs(i).name)
            If (rst.EOF = False) Then
                rst.MoveFirst
            End If
            Do While Not rst.EOF
                rstTo.AddNew
                For j = 0 To rst.fields.Count - 1
                    rstTo(rst.fields(j).name) = rst(rst.fields(j).name)
                Next j
                rstTo.Update
                rst.MoveNext
            Loop
        End If
    Next i
    
    If (UsePassword = True) Then
        ToDataBase.newPassword "", Password
    End If
    
    rst.Close
    rstTo.Close
    db.Close
    ToDataBase.Close
    
    WriteToLogFile "Line 147 reached in CreateNewDatabase. databaseFrom is: " & databasefrom
    
    Kill databasefrom '<- program stops here
    
    Name Replace(databasefrom, ".mdb", "temp.mdb") As databasefrom
    This only seems to occur when all three databases are in the same folder but when they are all in separate folders it throws this error but only on one particular database

    It may be difficult to determine but anyone have any idea why? (I don't think its a permissions thing)

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Is this one particular database open at the time?

  3. #3
    Join Date
    Feb 2008
    Posts
    52
    No its definately closed beforehand->

    Code:
    If (val(dbMnuSource.Version) <= DataBaseVersion) Then
            dbMnuSource.Close
            WriteToLogFile "Line 1585 reached in upgradeProgram"
            CreateNewDataBase systemConfig.menuDataPath & "\ts32_mnu.mdb", False
            'ConvertDBto2003 systemConfig.menuDataPath & "\ts32_mnu.mdb", False, dbMnuSource
        End If

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Have you checked its attributes?

    Has the read-only flag been tripped?

  5. #5
    Join Date
    Feb 2008
    Posts
    52
    How could I determine this?

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    From Windows Explorer, navigate to the database location, right click on it, and click properties.

    Check the Attributes.

  7. #7
    Join Date
    Feb 2008
    Posts
    52
    Actually I've just found that you may be right about the database not being closed. However, in development mode, the database is definately closed prior to the Kill function being called (unless somehow the wrong database is being closed) whereas in release it seems to still be open which is why this error is occuring

  8. #8
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    What would cause it to remain open? Is it still in use by a user?

  9. #9
    Join Date
    Feb 2008
    Posts
    52
    No, it should have been closed with the db.Close statement in

    Code:
    rst.Close
    rstTo.Close
    db.Close
    ToDataBase.Close
    
    Debug.Print "databasefrom: " & databasefrom
    Debug.Print "tempDatabaseName: " & tempDatabaseName
    
    WriteToLogFile "databasefrom: " & databasefrom
    WriteToLogFile "tempDatabaseName: " & tempDatabaseName
    
    Kill databasefrom
    And its definately not opened by another user

    The strange thing is this works for the other 2 databases no problem

  10. #10
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    As a test, don't do the other two databases (on which you are not having a proble).

    Run you code just on this one database by itself and see what happens.

  11. #11
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Oh, and did you check the attributes on this one database or not?

Similar Threads

  1. permission denied
    By brad35309 in forum VB Classic
    Replies: 0
    Last Post: 12-18-2005, 04:12 PM
  2. Replies: 1
    Last Post: 09-21-2005, 09:57 AM
  3. query tuning
    By dhaya in forum Database
    Replies: 11
    Last Post: 08-25-2003, 05:24 PM
  4. Beta2 Southern Hemisphere Blues
    By Esmond Hart in forum .NET
    Replies: 2
    Last Post: 01-14-2002, 08:24 AM
  5. Re: Runtime-error 70 Permission Denied with DCOM
    By Tom Shreve in forum Enterprise
    Replies: 1
    Last Post: 05-04-2000, 10:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center