Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Save (backup) an access file

Hi,

I have an application that uses an Access database.
Now i want the user to be able to make a backup of this database.
I heard it can be done with the SaveFileDialog, but can someone please give me an example code.

What i want:
The dialog must display the default location where the original database is located. Then the user must select this database and give it another location where it can be saved so the user has a backup.

Comments

  • Termc1224Termc1224 Member Posts: 84
    : Hi,
    :
    : I have an application that uses an Access database.
    : Now i want the user to be able to make a backup of this database.
    : I heard it can be done with the SaveFileDialog, but can someone please give me an example code.
    :
    : What i want:
    : The dialog must display the default location where the original database is located. Then the user must select this database and give it another location where it can be saved so the user has a backup.
    :
    First add a Commondialog Control on the Form
    1 textbox
    2 Command Button
    name 1 command button as Backup
    name the 2nd command button as save_as
    Put this in your save_as command button
    commondialog1.opensaveas
    text1.text = commondialog1.filename

    Put this in your Backup Command Button
    dim f1 as string, f2 as string
    dim l as long, txt as byte
    f1 = put database path and filename here
    f2 = text1.text
    open f1 for binary as 1
    open f2 for binary as 2
    l = 1
    while l <= lof(1)
    get l, 1, txt
    put l, 2, txt
    l = l + 1
    wend
    msgbox("Backup Successful")

    Hope this help
  • Termc1224Termc1224 Member Posts: 84
    : : Hi,
    : :
    : : I have an application that uses an Access database.
    : : Now i want the user to be able to make a backup of this database.
    : : I heard it can be done with the SaveFileDialog, but can someone please give me an example code.
    : :
    : : What i want:
    : : The dialog must display the default location where the original database is located. Then the user must select this database and give it another location where it can be saved so the user has a backup.
    : :
    : First add a Commondialog Control on the Form
    : 1 textbox
    : 2 Command Button
    : name 1 command button as Backup
    : name the 2nd command button as save_as
    : Put this in your save_as command button
    : commondialog1.opensaveas
    : text1.text = commondialog1.filename
    :
    : Put this in your Backup Command Button
    : dim f1 as string, f2 as string
    : dim l as long, txt as byte
    : f1 = put database path and filename here
    : f2 = text1.text
    : open f1 for binary as 1
    : open f2 for binary as 2
    : l = 1
    : while l <= lof(1)
    : get l, 1, txt
    : put l, 2, txt
    : l = l + 1
    : wend
    : msgbox("Backup Successful")
    :
    : Hope this help
    :
    sori my mistake
    change get l, 1, txt to get 1,l, txt
    change put l, 2, txt to put 2,l,txt


  • BarkeeperBarkeeper Member Posts: 335
    : : Hi,
    : :
    : : I have an application that uses an Access database.
    : : Now i want the user to be able to make a backup of this database.
    : : I heard it can be done with the SaveFileDialog, but can someone please give me an example code.
    : :
    : : What i want:
    : : The dialog must display the default location where the original database is located. Then the user must select this database and give it another location where it can be saved so the user has a backup.
    : :
    : First add a Commondialog Control on the Form
    : 1 textbox
    : 2 Command Button
    : name 1 command button as Backup
    : name the 2nd command button as save_as
    : Put this in your save_as command button
    : commondialog1.opensaveas
    : text1.text = commondialog1.filename
    :
    : Put this in your Backup Command Button
    : dim f1 as string, f2 as string
    : dim l as long, txt as byte
    : f1 = put database path and filename here
    : f2 = text1.text
    : [red]open f1 for binary as 1
    : open f2 for binary as 2
    : l = 1
    : while l <= lof(1)
    : get l, 1, txt
    : put l, 2, txt
    : l = l + 1
    : wend[/red]
    : msgbox("Backup Successful")
    :
    : Hope this help
    :

    ermm.....? Why not just use the Windows-API for copying the file? Look up the API "SHFileOperation".
    ------------------------------------------
    Only stupidity of mankind and the universe
    are infinite, but i'm not sure concerning
    the universe. A. Einstein

  • vbnewbiejoepvbnewbiejoep Member Posts: 39
    Hi,

    thanks for everyone's help, but there is one problem.
    I can simply copy the Access database to a directory:
    [code]System.IO.File.Copy(apppath & "bdb1.mdb", destFilename, True)[/code]

    But I don't want to copy the whole .mbd file. I only want to backup (copy) certain Tables in the .mbd file. Becouse I want the user to be able to choose what database (which table in the .mdb file) they wish to backup or restore.


  • BarkeeperBarkeeper Member Posts: 335
    : Hi,
    :
    : thanks for everyone's help, but there is one problem.
    : I can simply copy the Access database to a directory:
    : [code]System.IO.File.Copy(apppath & "bdb1.mdb", destFilename, True)[/code]
    :
    : But I don't want to copy the whole .mbd file. I only want to backup (copy) certain Tables in the .mbd file. Becouse I want the user to be able to choose what database (which table in the .mdb file) they wish to backup or restore.
    :
    :
    :

    Look up the SQL-Language, especially the "SELECT ... INTO"-STatement.

    Zvoni
    ------------------------------------------
    Only stupidity of mankind and the universe
    are infinite, but i'm not sure concerning
    the universe. A. Einstein

Sign In or Register to comment.