mysql 备份 access数据库_ACCESS数据库备份与恢复

private Sub mnu_sj_bf_Click()

Dim i As String

On Error Resume Next

With cdlog1

.DialogTitle = "数据备份"

.InitDir = App.Path

.filename = "backup.mdb"

.Filter = "(数据库)*.mdb|*.mdb"

.CancelError = True

.ShowSave

i = .filename

End With

If Right$(App.Path, 1) <> "\" Then spath = App.Path & "\"

ssource = spath & "mdb\che.lbl"

sdest = i

If Err.Number <> cdlCancel Then

On Error GoTo sjbf_error

If Dir$(i) <> "" Then

s = MsgBox("文件已存在,确认替换它!", vbYesNo + vbQuestion)

If s = 6 Then

'FileCopy ssource, sdest

Kill sdest

DBEngine.CompactDatabase ssource, sdest

MsgBox "数据备份成功!", vbInformation

Else

mnu_sj_bf_Click

End If

Else

'FileCopy ssource, sdest

DBEngine.CompactDatabase ssource, sdest

MsgBox "数据备份成功!", vbInformation

End If

End If

Exit Sub

sjbf_error:

If Err = 70 Then

MsgBox "数据库正在使用,请关闭所有数据窗口,从新开始备份", vbExclamation

Else

MsgBox Err.Description, vbExclamation

End If

End Sub

Private Sub mnu_sj_hf_Click()

Dim i As String

On Error Resume Next

With cdlog1

.DialogTitle = "数据恢复"

.InitDir = App.Path

.Filter = "(数据库)*.mdb|*.mdb"

.CancelError = True

.Flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist

.ShowOpen

i = .filename

End With

ssource = i

If Right$(App.Path, 1) <> "\" Then spath = App.Path & "\"

sdest = spath & "mdb\che.lbl"

temp1 = fullpath("mdb\backup.mdb")

' If Dir(temp1) = True Then Kill

If Err.Number <> cdlCancel Then

On Error GoTo sjh_error

s = MsgBox("系统数据将全部丢失,确认要从数据文件" & i & "中恢复系统数据吗?", vbYesNo + vbQuestion)

If s = 6 Then

FileCopy sdest, temp1

FileCopy ssource, sdest

MsgBox "数据恢复成功!", vbInformation

End If

End If

Exit Sub

sjh_error:

If Err = 70 Then

MsgBox "数据库正在使用,请关闭所有数据窗口,从新开始恢复", vbExclamation

Else

MsgBox Err.Description, vbExclamation

End If

End Sub

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值