📄 frmrestore.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmrestore
BorderStyle = 0 'None
ClientHeight = 3390
ClientLeft = 4740
ClientTop = 3105
ClientWidth = 6930
LinkTopic = "Form1"
ScaleHeight = 3390
ScaleWidth = 6930
ShowInTaskbar = 0 'False
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4920
Top = 360
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Frame Frame1
Height = 2175
Left = 360
TabIndex = 1
Top = 840
Width = 6135
Begin VB.CommandButton Command3
Caption = "放弃还原数据"
Height = 375
Left = 3120
TabIndex = 7
Top = 1560
Width = 2055
End
Begin VB.CommandButton Command2
Caption = "开始还原数据"
Height = 375
Left = 360
TabIndex = 6
Top = 1560
Width = 2055
End
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 255
Left = 120
TabIndex = 5
Top = 1080
Width = 5775
_ExtentX = 10186
_ExtentY = 450
_Version = 393216
Appearance = 1
End
Begin VB.CommandButton Command1
Caption = "..."
Height = 255
Left = 5520
TabIndex = 4
Top = 360
Width = 495
End
Begin VB.TextBox Text1
Height = 270
Left = 2040
TabIndex = 3
Top = 360
Width = 3375
End
Begin VB.Label Label1
Caption = "请选择数据还原目录:"
Height = 375
Left = 240
TabIndex = 2
Top = 360
Width = 1815
End
End
Begin VB.Image imgTitleMaximize
Height = 195
Left = 4920
Picture = "frmrestore.frx":0000
ToolTipText = "Maximize (Disabled)"
Top = 120
Visible = 0 'False
Width = 195
End
Begin VB.Image imgTitleclose
Height = 195
Left = 5880
Picture = "frmrestore.frx":024A
ToolTipText = "Close"
Top = 120
Width = 195
End
Begin VB.Image imgTitleHelp
Height = 210
Left = 5280
Picture = "frmrestore.frx":0494
Stretch = -1 'True
Top = 120
Width = 210
End
Begin VB.Image imgTitleMinimize
Height = 210
Left = 5520
Picture = "frmrestore.frx":06DE
Stretch = -1 'True
Top = 120
Width = 210
End
Begin VB.Label lblTitle
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数据库还原"
BeginProperty Font
Name = "Arial"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 240
Left = 3000
TabIndex = 0
Top = 120
Width = 1275
End
Begin VB.Image Imageicon
Height = 315
Left = 1920
Picture = "frmrestore.frx":0928
Stretch = -1 'True
Top = 120
Width = 315
End
Begin VB.Image imgWindowLeft
Height = 450
Left = 1080
Picture = "frmrestore.frx":2DCA
Stretch = -1 'True
Top = 480
Width = 285
End
Begin VB.Image imgWindowRight
Height = 450
Left = 720
Picture = "frmrestore.frx":3514
Stretch = -1 'True
Top = 480
Width = 285
End
Begin VB.Image imgTitleLeft
Height = 450
Left = 0
Picture = "frmrestore.frx":3C5E
Top = 0
Width = 285
End
Begin VB.Image imgTitleRight
Height = 450
Left = 360
Picture = "frmrestore.frx":43A8
Top = 0
Width = 285
End
Begin VB.Image imgWindowBottom
Height = 450
Left = 360
Picture = "frmrestore.frx":4AF2
Stretch = -1 'True
Top = 480
Width = 285
End
Begin VB.Image imgTitleMain
Height = 450
Left = 0
Picture = "frmrestore.frx":523C
Stretch = -1 'True
Top = 450
Width = 285
End
Begin VB.Image imgWindowBottomLeft
Height = 450
Left = 720
Picture = "frmrestore.frx":5986
Top = 0
Width = 285
End
Begin VB.Image imgWindowBottomRight
Height = 450
Left = 1080
Picture = "frmrestore.frx":60D0
Top = 0
Width = 285
End
End
Attribute VB_Name = "frmrestore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
CommonDialog1.FontName = ""
CommonDialog1.Flags = 512
CommonDialog1.InitDir = "d:\temp"
CommonDialog1.Filter = "还原文件(*.bak)|*.bak "
CommonDialog1.ShowSave
Text1.Text = CommonDialog1.filename
End Sub
Private Sub Command2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strsql As String
Dim connstrings As String
Dim counter As Integer
Dim rs As New ADODB.Recordset
ProgressBar1.Min = 0
ProgressBar1.Max = 1000
ProgressBar1.Visible = True
ProgressBar1.Value = ProgressBar1.Min
MyDB.conn.Close
Set MyDB.conn = Nothing
MyDB.conn.Open "driver={SQL Server};server=" + Trim(Server) + ";Trusted_Connection=yes;database=pubs"
strsql = "drop database stuchoose"
MyDB.conn.Execute strsql
strsql = "restore database stuchoose from disk='" & Text1.Text & "'"
If (Len(Trim(Text1.Text)) = 0) Then
Result = MsgBox("请指定所要还原数据的路径!", vbOKOnly, "数据还原")
Exit Sub
Else
For counter = ProgressBar1.Min To ProgressBar1.Max
ProgressBar1.Value = counter
Next counter
On Error Resume Next
MyDB.conn.Execute strsql
ProgressBar1.Visible = False
ProgressBar1.Value = ProgressBar1.Min
MyDB.conn.Close
Set MyDB.conn = Nothing
If frmserver.SSTab1 = 0 Then
MyDB.conn.Open "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=stuchoose"
Else
MyDB.conn.Open "driver={SQL Server};server=" + Trim(Server) + ";Trusted_Connection=yes;database=stuchoose"
End If
Result = MsgBox("本系统数据库中的数据还原完毕,请保存数据还原目录下的数据还原文件!", vbOKOnly, "数据还原")
Unload Me
End If
Exit Sub
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
MakeWindow Me
ProgressBar1.Visible = False
End Sub
Private Sub imgTitleclose_Click()
intNumField = -2
Unload Me
End Sub
Private Sub imgTitleLeft_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
Private Sub imgTitleMain_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
Private Sub imgTitleMinimize_Click()
Me.WindowState = 1
End Sub
Private Sub imgTitleRight_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -