🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.bazy-danych.msaccess
1 messages
1 total messages Started by Phantom Mon, 23 Mar 2020 04:53
Naprawa bazy danych
#134018
Author: Phantom
Date: Mon, 23 Mar 2020 04:53
69 lines
2660 bytes
Witam
Kod na naprawę bazy danych przestał działać.
Przesiadłem się z Access2000 na Access2019 i poniższy kod przestał mi działać.
Jest to skrypt vbs dla MSAccess2000 czyli ("Access.Application.9").
Teraz mam bazę z rozszerzeniem accdb.
Próbowałem zmieniać w treści kodu z Access.Application.9 na wyższy numer ale nic to nie daje.
Proszę o pomoc.

    ' *****************  BEGIN CODE HERE  ' *****************
    '
    Dim objScript
    Dim objAccess
    Dim strPathToMDB
    Dim strMsg

    ' ///////////// NOTE:  User must edit variables in this section /////
    '
    '  The following line of code is the only variable that need be edited
    '  You must provide a path to the Access MDB which will be compacted
    '
            strPathToMDB = "C:\Users\mduda\Desktop\Awaria\Dp07baza.accdb"
    '
    ' ////////////////////////////////////////////////////////////////

    ' Set a name and path for a temporary mdb file
     strTempDB = "C:\Users\mduda\Desktop\Awaria\Comp0001.accdb"

    ' Create Access 97 Application Object
    'Set objAccess = CreateObject("Access.Application.8")

    ' For Access 2000, use Application.9
    Set objAccess = CreateObject("Access.Application.9")

    ' Perform the DB Compact into the temp mdb file
    ' (If there is a problem, then the original mdb is  preserved)
    'objAccess.DbEngine.CompactDatabase strPathToMDB ,strTempDB
    objAccess.DbEngine.CompactDatabase strPathToMDB ,strTempDB, , , ";pwd=" & "1234"


    If Err.Number > 0 Then
        ' There was an error.  Inform the user and halt execution
        strMsg = "The following error was encountered while compacting database:"
        strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
    Else
        ' Create File System Object to handle file manipulations
        Set objScript= CreateObject("Scripting.FileSystemObject")
    
        ' Back up the original file as Filename.mdbz.  In case of undetermined
        ' error, it can be recovered by simply removing the terminating "z".
        'objScript.CopyFile strPathToMDB , strPathToMDB & "z", True
        objScript.CopyFile strPathToMDB , strPathToMDB & "_" & Date(), True

        ' Copy the compacted mdb by into the original file name
        objScript.CopyFile strTempDB, strPathToMDB, True

        ' We are finished with TempDB.  Kill it.
        objScript.DeleteFile strTempDB
    End If

    ' Always remember to clean up after yourself
    Set objAccess = Nothing
    Set objScript = Nothing
    '    
    ' ******************  END CODE HERE  ' ******************
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads