bak_res_frm.frm

来自「学校田径运动会管理系统是典型的信息管理系统」· FRM 代码 · 共 81 行

FRM
81
字号
VERSION 5.00
Begin VB.Form bak_res_frm 
   Caption         =   "数据备份还原"
   ClientHeight    =   2745
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   3720
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   2745
   ScaleWidth      =   3720
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "恢复数据库"
      Height          =   495
      Left            =   1920
      TabIndex        =   1
      Top             =   840
      Width           =   1455
   End
   Begin VB.CommandButton Command1 
      Caption         =   "备份数据库"
      Height          =   495
      Left            =   360
      TabIndex        =   0
      Top             =   840
      Width           =   1455
   End
End
Attribute VB_Name = "bak_res_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As ADODB.Connection, rs As ADODB.Recordset
Dim mypath As String

 
Private Sub Command1_Click()
    Dim FileName As String
    Dim FileBack As String
    Dim Info As String
    FileName = mypath & "db1.mdb"
    FileBack = mypath & "backup/db.bak"
    Info = "正在备份数据库" & FileName
    BackupDatabase FileName, FileBack, Info
    MsgBox "备份数据库成功!", vbInformation, "提示"
End Sub
Private Sub BackupDatabase(SourceName As String, BackupName As String, Info As String)
'备份数据库
    On Error Resume Next
    
    FileCopy SourceName, BackupName
    On Error GoTo 0
End Sub

Private Sub Command2_Click()
    Dim FileRestore As String
    Dim FileBack As String
    Dim Info As String
    Set conn = New ADODB.Connection
    
    FileRestore = mypath & "db1.mdb"
    FileBack = mypath & "backup/db.bak"
    Info = "正在还原数据库" & FileRestore
    RestoreDatabase FileRestore, FileBack, Info
    MsgBox "还原数据库成功!", vbInformation, "提示"
End Sub
Private Sub RestoreDatabase(SourceName As String, BackupName As String, Info As String)
'还原数据库
    On Error Resume Next
    FileCopy BackupName, SourceName
    On Error GoTo 0
End Sub

Private Sub Form_Load()
mypath = App.Path & "/data"  '获取当前路径
If Right(mypath, 1) <> "/" Then mypath = mypath + "/"

End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?