如何备份和恢复有密码的 ACCESS 2000

解决方案 »

  1.   

    如果没有特殊要求
    ACCESS备份把数据库直接拷贝到另一个地方即可
    还原就是再拷贝回来覆盖掉
    这样比较简单
      

  2.   

    Dim itmX, key As String     '定义字符串变量
    Dim a As Integer     '定义整型变量
    Private Sub Form_Load()
     Option1.Value = True
     Dir1_Change
    End Sub
    Private Sub Dir1_Change()
     File1.Path = Dir1.Path
     '添加数据备份卡到列表中
     ListView1.ListItems.Clear
     If File1.ListCount <> 0 Then
      a = 0
      Do While File1.ListIndex < File1.ListCount - 1
        File1.ListIndex = a
        key = File1.FileName
        Set itmX = ListView1.ListItems.Add(, , key, 1)
        a = a + 1
      Loop
     End If
     Label1.Caption = Dir1.Path & "\" & File1.FileName
    End Sub
    Private Sub Drive1_Change()
     Dir1.Path = Drive1.Drive
    End Sub
    Private Sub File1_Click()
     Label1.Caption = Dir1.Path & "\" & File1.FileName     '获取路径
    End Sub
    Private Sub Command1_Click()
     If Option1.Value = True Then
     '备份数据库
      If File1.ListCount <> 0 Then
       FileCopy Trim(Label1.Caption), Date & "备份卡" & File1.FileName
       Me.MousePointer = 0
       MsgBox "数据已备份完毕!"
       key = Date & "备份卡" & File1.FileName
       Set itmX = ListView1.ListItems.Add(, , key, 1)
      End If
     End If
     If Option2.Value = True Then
    '恢复指定路径下的数据库
      If File1.ListCount <> 0 Then
        FileCopy ListView1.SelectedItem, File1.FileName
        Me.MousePointer = 0
        MsgBox "数据已恢复完毕!"
       Else
        MsgBox "请选择要恢复的数据!"
       End If
     End If
    End Sub
    Private Sub Command2_Click()
     End
    End Sub
      

  3.   

    问题还没有解决
     下面是我的代码 
    我觉得不是 FILECOPY 有问题,而是VB6.0不支持拷ACCESS 2000的问题,各位有何高见?
      bakfilename = Trim(Text1.Text)
     If Me.Caption = "备份数据库" Then
     On Error GoTo ss
        If Len(Dir(bakfilename)) > 0 Then
            If MsgBox("此文件已存在,是否替换?", 1 + 32, "询问窗口") = 1 Then
               Fwait.Show
               Fwait.Refresh
               Kill bakfilename                       '删除已存在同名文件
            Else
              Text1.Text = ""
              Text1.SetFocus
              Exit Sub
            End If
        End If
         FileCopy App.Path + "\CY.mdb", Trim(Text1.Text)
         MsgBox "数据库已成功备份!", 0 + 48, "提示"
         Unload Fwait
         Unload Me
         Exit Sub
    ss:
         MsgBox Err.Description
         Unload Fwait
         Unload Me
    Else
      On Error GoTo xx
          If MsgBox("恢复前请先作好备份,确定恢复吗?", 1 + 32, "询问提示") = 1 Then
          Else
             Unload Me
             Exit Sub
          End If
            Fwait.Show
            Fwait.Refresh
           If Len(Dir(bakfilename)) <= 0 Then
             MsgBox "源文件不存在,不能恢复!", 0 + 16, "提示"
             Text1.SelStart = 0
             Text1.SelLength = Len(Text1.Text)
             Text1.SetFocus
             Unload Fwait
             Exit Sub
           End If
           
            Kill App.Path + "\CY.mdb"
            FileCopy Trim(bakfilename), App.Path + "\CY.mdb"
            MsgBox "数据库已成功恢复!", 0 + 48, "提示"
            Unload Fwait
            Unload Me
            Exit Sub
    xx:
          Unload Fwait
          MsgBox Err.Description
          Unload Me
        End If