📄 frm_otherset.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Frm_OtherSet
Caption = " 还 原 数 据 库"
ClientHeight = 4170
ClientLeft = 60
ClientTop = 450
ClientWidth = 6360
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Frm_OtherSet.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4170
ScaleWidth = 6360
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 2895
Left = 120
TabIndex = 3
Top = 120
Width = 6135
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "本软件采用的是SQL SERVER数据库;"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 285
Left = 360
TabIndex = 7
Top = 360
Width = 5115
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "数据库名为:WaterMang;"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 285
Left = 360
TabIndex = 6
Top = 1035
Width = 3690
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "若机器上没有装SQL SERVER,请先安装;"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 285
Left = 360
TabIndex = 5
Top = 1725
Width = 5745
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "第一次使用请点还原数据库。"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 285
Left = 360
TabIndex = 4
Top = 2400
Width = 4095
End
End
Begin VB.CommandButton Cmd_Restore
BackColor = &H8000000D&
Caption = "还原数据库"
Default = -1 'True
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 960
Style = 1 'Graphical
TabIndex = 1
Top = 3480
Width = 1695
End
Begin VB.CommandButton Cmd_O_Exit
BackColor = &H8000000D&
Caption = "退 出"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3720
Style = 1 'Graphical
TabIndex = 0
Top = 3480
Width = 1695
End
Begin MSComDlg.CommonDialog FileDialog
Left = 0
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
Filter = "*.dat"
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "首次运行用户名:admin;密码:admin"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 210
Left = 120
TabIndex = 2
Top = 3120
Width = 3795
End
End
Attribute VB_Name = "Frm_OtherSet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmd_O_Exit_Click()
Unload Me
End Sub
Private Sub Cmd_Restore_Click()
On Error GoTo Err:
d = MsgBox("系统将回到备份文件前的状态!确认要恢复已备份数据库吗?", vbOKCancel, "提示")
If d = vbOK Then
Me.MousePointer = 11
Dim r_str As String
Dim r_conn As ADODB.Connection
Dim r_rs As ADODB.Recordset
Dim r_rs1 As ADODB.Recordset
Set r_conn = New ADODB.Connection
Set r_rs = New ADODB.Recordset
Set r_rs1 = New ADODB.Recordset
Set r_comm = New ADODB.Command
r_conn.CursorLocation = adUseClient
r_conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;"
Set r_rs.ActiveConnection = r_conn
Set r_rs1.ActiveConnection = r_conn
FileDialog.DialogTitle = "数据恢复"
FileDialog.CancelError = True
FileDialog.ShowOpen
s = FileDialog.FileName
r_str = "select spid from master..sysprocesses where dbid=db_id('WaterMang')"
r_rs.Open r_str
If r_rs.RecordCount > 0 Then
For i = 1 To r_rs.RecordCount
r_str = "kill " & r_rs.Fields(0)
r_rs1.Open r_str
r_rs.MoveNext
If r_rs.EOF Then r_rs.MoveFirst
Next i
End If
r_rs.Close
r_str = "restore database WaterMang from disk='" & s & " '"
r_rs.Open r_str
MsgBox "数据恢复完成,请重新启动程序!"
Me.MousePointer = 0
End
Exit Sub
End If
Err:
Me.MousePointer = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -