frmbackup.frm

来自「学生信息管理系统,学生入学时间及毕业时间,学生成绩,学生所在系」· FRM 代码 · 共 144 行

FRM
144
字号
VERSION 5.00
Begin VB.Form FrmBackUp 
   BackColor       =   &H0000FF00&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "备份数据库"
   ClientHeight    =   3795
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9225
   Icon            =   "FrmBackUp.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3795
   ScaleWidth      =   9225
   Begin VB.CommandButton cmdExit 
      Caption         =   "关闭"
      Height          =   495
      Left            =   6840
      TabIndex        =   4
      Top             =   2640
      Width           =   1335
   End
   Begin VB.CommandButton cmdBackUp 
      Caption         =   "备份"
      Height          =   495
      Left            =   4920
      TabIndex        =   3
      Top             =   2640
      Width           =   1335
   End
   Begin VB.Label Label2 
      BackColor       =   &H8000000E&
      Caption         =   "注意:此备份目录程序将备份至*\SIMS_Frm\BackUp目录下"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   375
      Left            =   480
      TabIndex        =   2
      Top             =   1680
      Width           =   7575
   End
   Begin VB.Label lbTime 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Height          =   180
      Left            =   240
      TabIndex        =   1
      Top             =   720
      Visible         =   0   'False
      Width           =   90
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "警告:单击“备份”按钮,开始备份数据库。"
      BeginProperty Font 
         Name            =   "微软雅黑"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   390
      Left            =   480
      TabIndex        =   0
      Top             =   240
      Width           =   5700
   End
End
Attribute VB_Name = "FrmBackUp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cn As ADODB.Connection
Dim success As Long
Dim fso As New FileSystemObject, fldr As Folder

Private Sub cmdBackUp_Click()
Dim backFile As String
Dim NowTime As String
Dim sql As String
Dim buff As String
If fso.FolderExists(App.Path & "\BackUp") = False Then
    Set fldr = fso.CreateFolder(App.Path & "\BackUp")
End If
NowTime = Format(Now, "yyyy-mm-dd_hh-mm-ss")
backFile = "Sims_four" & NowTime
sql = "BACKUP DATABASE Sims_four TO disk='" & App.Path & "\BackUP\" & backFile & "'"
cn.Execute (sql)
MsgBox "数据库备份成功!" & vbCrLf & "文件:" & backFile, vbOKOnly + vbInformation, "备份数据库"
success = WritePrivateProfileString("BackUp", "NewFile", backFile, App.Path & "\Sims.ini")

buff = String(255, 0)
ret = GetPrivateProfileString("BackUp", "Time", "1", buff, 256, App.Path & "\Sims.ini")
lbTime.Caption = buff
Select Case lbTime.Caption
Case "1"
success = WritePrivateProfileString("BackUp", "File1", backFile, App.Path & "\Sims.ini")
Case "2"
success = WritePrivateProfileString("BackUp", "File2", backFile, App.Path & "\Sims.ini")
Case "3"
success = WritePrivateProfileString("BackUp", "File3", backFile, App.Path & "\Sims.ini")
Case "4"
success = WritePrivateProfileString("BackUp", "File4", backFile, App.Path & "\Sims.ini")
Case "5"
success = WritePrivateProfileString("BackUp", "File5", backFile, App.Path & "\Sims.ini")
End Select
lbTime.Caption = lbTime.Caption + 1
If lbTime.Caption = 6 Then
   lbTime.Caption = 1
End If
success = WritePrivateProfileString("BackUp", "Time", lbTime.Caption, App.Path & "\Sims.ini")
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set cn = New ADODB.Connection
If cn.State = adStateOpen Then cn.Close
With cn
    .ConnectionTimeout = 10
    .Provider = "sqloledb"
    .ConnectionString = "data source=.;initial catalog=master;user id=sa;password=;"
    .Open
End With
End Sub

⌨️ 快捷键说明

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