📄 frm_restore.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
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 frm_restore
Caption = "数据恢复"
ClientHeight = 3870
ClientLeft = 60
ClientTop = 345
ClientWidth = 5760
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 3870
ScaleWidth = 5760
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 120
Top = 4560
Visible = 0 'False
Width = 2175
_ExtentX = 3836
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Building"
OLEDBString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Building"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from tb_enter"
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 VB.TextBox Text3
Height = 270
Left = 3120
TabIndex = 3
Text = "Text3"
Top = 5400
Width = 1215
End
Begin VB.CommandButton Cmd_Cancel
Caption = "取消"
Height = 375
Left = 4560
TabIndex = 0
Top = 3480
Width = 1095
End
Begin VB.CommandButton Cmd_Ok
Caption = "开始恢复"
Height = 375
Left = 3405
TabIndex = 2
Top = 3480
Width = 1095
End
Begin VB.PictureBox Picture2
Height = 3255
Left = 120
Picture = "frm_restore.frx":0000
ScaleHeight = 3195
ScaleWidth = 1755
TabIndex = 1
Top = 120
Width = 1815
End
Begin VB.Frame Frame2
Height = 3375
Left = 2040
TabIndex = 4
Top = 0
Width = 3615
Begin VB.TextBox Txt_restore
Height = 300
Left = 120
TabIndex = 7
Top = 2520
Width = 3015
End
Begin VB.CommandButton Cmd_select
Caption = "<<"
Height = 300
Left = 3120
TabIndex = 6
Top = 2520
Width = 375
End
Begin MSComDlg.CommonDialog CommonDialog2
Left = 2880
Top = 1680
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MSComctlLib.ProgressBar ProgressBar2
Height = 300
Left = 120
TabIndex = 5
Top = 3000
Width = 3375
_ExtentX = 5953
_ExtentY = 529
_Version = 393216
Appearance = 1
End
Begin VB.Label Label2
Caption = "选择数据库恢复的路径"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C000C0&
Height = 300
Left = 120
TabIndex = 9
Top = 2160
Width = 2415
End
Begin VB.Label Label3
Caption = "单击“<<”图标按钮,选择以前备份的数据库路径,然后单击“开始恢复”按钮开始恢复数据"
Height = 615
Index = 0
Left = 480
TabIndex = 8
Top = 960
Width = 2775
End
End
End
Attribute VB_Name = "frm_restore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Const INFINITE = -1&
Private Const SYNCHRONIZE = &H100000
Dim StrCnn As New Connection '定义连接
Dim key, list, sql, Temp, Intext As String '定义字符串变量
Private Sub Cmd_Ok_Click()
Me.MousePointer = 11
Cmd_Ok.Enabled = False
If Txt_restore.Text = "" Then
MsgBox "请您选择数据库恢复的路径!", 64, "提示信息"
Else
Dim connter As Integer
Dim sql, workarea(12) As String
ProgressBar2.Visible = True
ProgressBar2.Max = UBound(workarea)
ProgressBar2.Value = ProgressBar2.Min
For connter = LBound(workarea) To UBound(workarea)
workarea(connter) = "initial value" & connter
ProgressBar2.Value = connter
StrCnn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master"
sql = "use master RESTORE DATABASE db_Goods from disk='" & Txt_restore.Text & "'"
StrCnn.Execute (sql) '执行SQL语句
StrCnn.Close
Next connter
ProgressBar2.Value = ProgressBar2.Min
MsgBox "数据库恢复成功!!", 64, "提示信息"
Cmd_Ok.Enabled = True
Me.MousePointer = 0
End If
End Sub
Private Sub Cmd_select_Click()
CommonDialog2.Filter = "备份文件(*.bak)|*.bak|文本文件(*.txt)|*.txt|ALL File(*.*)|*.*"
CommonDialog2.ShowOpen
Txt_restore.Text = CommonDialog2.FileName
End Sub
Private Sub Cmd_Cancel_Click()
End
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -