⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 数据库备份.frm

📁 学生管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form 数据库备份 
   Caption         =   "数据库备份"
   ClientHeight    =   4965
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8010
   ForeColor       =   &H00E0E0E0&
   LinkTopic       =   "Form1"
   ScaleHeight     =   4965
   ScaleWidth      =   8010
   StartUpPosition =   3  '窗口缺省
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   480
      Top             =   5400
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSComctlLib.ProgressBar ProgressBar1 
      Height          =   375
      Left            =   0
      TabIndex        =   8
      Top             =   3840
      Width           =   7815
      _ExtentX        =   13785
      _ExtentY        =   661
      _Version        =   393216
      Appearance      =   1
   End
   Begin VB.CommandButton Command3 
      Caption         =   "数据库恢复"
      Height          =   495
      Left            =   2040
      TabIndex        =   7
      Top             =   4440
      Width           =   1575
   End
   Begin VB.Frame Frame2 
      Caption         =   "选择数据库路径"
      Height          =   3015
      Left            =   3840
      TabIndex        =   3
      Top             =   720
      Width           =   3975
      Begin VB.DirListBox Dir1 
         Height          =   720
         Left            =   120
         TabIndex        =   5
         Top             =   600
         Width           =   3615
      End
      Begin VB.FileListBox File1 
         Height          =   1530
         Left            =   120
         Pattern         =   "*.bak"
         TabIndex        =   6
         Top             =   1320
         Width           =   3615
      End
      Begin VB.DriveListBox Drive1 
         Height          =   300
         Left            =   120
         TabIndex        =   4
         Top             =   240
         Width           =   3615
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   495
      Left            =   6000
      TabIndex        =   2
      Top             =   4440
      Width           =   1575
   End
   Begin VB.CommandButton Command1 
      Caption         =   "数据库备份"
      Height          =   495
      Left            =   3840
      TabIndex        =   1
      Top             =   4440
      Width           =   1935
   End
   Begin VB.Frame Frame1 
      Caption         =   "备份卡"
      Height          =   3015
      Left            =   0
      TabIndex        =   0
      Top             =   720
      Width           =   3615
      Begin VB.TextBox Text2 
         Height          =   1335
         Left            =   120
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   10
         Top             =   1560
         Width           =   3375
      End
      Begin VB.TextBox Text1 
         Height          =   1215
         Left            =   120
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   9
         Top             =   240
         Width           =   3375
      End
   End
End
Attribute VB_Name = "数据库备份"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As New ADODB.Recordset
Private sql As String
Dim workarea(12) As String
Dim StrCnn  As ADODB.Connection

Private Sub Command1_Click()  '数据备份
 Dim Myfile As String
   Command1.Enabled = False
 Command3.Enabled = False
 Command2.Enabled = False
  Myfile = Text1.text & "\" & Format(Date, "YYYY-MM-DD") & ":" & Format(Time, "hh") & ".BAK"
  Set rs = New ADODB.Recordset
  ProgressBar1.Visible = True
  ProgressBar1.Max = UBound(workarea)
  ProgressBar1.Value = ProgressBar1.Min
  For Counter = LBound(workarea) To UBound(workarea)
      workarea(Counter) = "initial value" & Counter
      ProgressBar1.Value = Counter
      sql = "BACKUP DATABASE xscj TO DISK ='" & Myfile & " '"
      Set rs = ESQL(sql)
  Next Counter
  ProgressBar1.Value = ProgressBar1.Min
  MsgBox "数据库备份成功!"
   Command1.Enabled = True
 Command3.Enabled = True
 Command2.Enabled = True
End Sub

Private Sub Command2_Click()
  Unload Me
 
End Sub

Private Sub Command3_Click()
 Command1.Enabled = False
 Command3.Enabled = False
 Command2.Enabled = False
 On Error GoTo ResErr
Dim Counter As Integer
ProgressBar1.Max = UBound(workarea)
ProgressBar1.Value = ProgressBar1.Min
  For Counter = LBound(workarea) To UBound(workarea)
      workarea(Counter) = "initial value" & Counter
      ProgressBar1.Value = Counter
          Set StrCnn = New ADODB.Connection
          StrCnn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master"
          sql = "use master RESTORE DATABASE db_Client from disk='" & Text2.text & "'"
          StrCnn.Execute (sql)     '执行SQL语句
          StrCnn.Close
  Next Counter
  ProgressBar1.Value = ProgressBar1.Min
     MsgBox "数据库恢复成功!!", 64, "提示信息"
     Command1.Enabled = True
     Command3.Enabled = True
     Command2.Enabled = True
  Exit Sub
ResErr:
  MsgBox "由于系统数据量大,数据库恢复已经超时,请退出系统重新操作数据备份!!!", , "系统提示"
  Command1.Enabled = True
  Command3.Enabled = True
  Command2.Enabled = True
  End
End Sub

Private Sub Dir1_Change()
  File1.Path = Dir1.Path
End Sub

Private Sub Dir1_Click()
  Text1.text = Dir1.Path
End Sub
Private Sub Drive1_Change()
  Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
  
  Text2.text = Dir1.Path & "\" & File1.FileName
End Sub

⌨️ 快捷键说明

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