Results 1 to 7 of 7

Thread: Automatically Backing up Access Database

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    canada
    Posts
    8

    Exclamation Automatically Backing up Access Database

    Hi!

    I have a problem and I need a very quick HELP!
    I need to backup and access2000 database automatically (every hour) using VB 6.0. I need the exact code in order to perform that task. Please if someone can help me, I would be greatful.

    By the way.....the database ahas a password.

    Thank you.


  2. #2
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    You could use this. This is the compact routine but can act as a sort of backup

    Make sure you reference the Microsoft ADO Ext. 'Version' for DDL and Security.

    VB Code:
    1. Dim je As New JRO.JetEngine
    2.  
    3.    ' Make sure there isn't already a file with the
    4.    ' name of the compacted database.
    5.    If Dir("C:\BackUp\YourDB.mdb") <> "" Then Kill ".\NewNorthWind.mdb"
    6.  
    7.    ' Compact the database
    8.    je.CompactDatabase "Data Source=C:\YourDB.mdb;Jet OLEDB: Database Password=password;", _
    9.       "Data Source=C:\BackUp\YourDB.mdb;"
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    canada
    Posts
    8
    I thank you ver much for your time sir.

    What I need though, is that the backup to take effect automatically every hour of the day.

    Please help me on that.

    P.S. Is compacting same as backup?


  4. #4
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    San Jose, Ca. - USA
    Posts
    302

    you could use a timer

    you could place a timer control on a hidden form. This form should also display a label control which tells the user that a backup is taking place, and to wait. Place something like this on your hidden form:
    ------------------------
    Dim i As Byte

    Private Sub Form_Load()
    i = 0
    End Sub

    Private Sub Timer1_Timer()
    i = i + 1
    If i = 60 Then
    Form1.Show vbModal
    Timer1.Enabled = False
    '1. disconnect from the databse
    '2. compact or copy database
    '3. reconnect to databse
    i = 0
    Timer1.Enabled = True
    Form1.Hide
    End If
    End Sub
    -----------------------------

    note that the timer control is kinda unreliable and that it is better to use the windows api functions.

    this is just an idea, sorry i can't give exact code.
    well gotta i go study now, good luck.

  5. #5
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    San Jose, Ca. - USA
    Posts
    302
    sorry i forgot to mntion that your timer interval should be set to 60000, so that it will go off every minute.

  6. #6
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    St. Albans, Herts, UK
    Posts
    259
    Why not replicate your database, then set a timer to go off every hour and synchronise the two. You do not need to disconnect any users, as you would for compacting, as the synch process can be carried out on open and active databases.
    Graham, www.gab2001uk.com VBExplorer Forum Moderator VBExplorer
    www.gab2001uk.com For comparing and contrasting DAO with ADO
    Code for Creating, Copying, Compacting, Replicating, Synchronising Access 97/2000 databases plus showing Schemas and using .Seek

  7. #7
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    St. Albans, Herts, UK
    Posts
    259
    Here 2 projects that do just that. One uses DAO the other ADO / ADOX / JRO.
    Have fun
    Graham, www.gab2001uk.com VBExplorer Forum Moderator VBExplorer
    www.gab2001uk.com For comparing and contrasting DAO with ADO
    Code for Creating, Copying, Compacting, Replicating, Synchronising Access 97/2000 databases plus showing Schemas and using .Seek

Posting Permissions

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



Click Here to Expand Forum to Full Width