?? frmrestore.frm
字號:
VERSION 5.00
Object = "{CE671F01-259E-40DA-92FE-95803E2ECBB5}#1.0#0"; "SmartXPButton.ocx"
Begin VB.Form FrmRestore
BackColor = &H00E7DFE7&
BorderStyle = 1 'Fixed Single
Caption = "還原數(shù)據(jù)庫"
ClientHeight = 2775
ClientLeft = 45
ClientTop = 330
ClientWidth = 4470
Icon = "FrmRestore.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2775
ScaleWidth = 4470
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox cboFile
Height = 300
Left = 240
TabIndex = 1
Top = 720
Width = 3975
End
Begin VB.CheckBox Check1
BackColor = &H00E7DFE7&
Caption = "選擇最新的備份文件"
Height = 375
Left = 240
TabIndex = 0
Top = 1440
Width = 2055
End
Begin SmartXPButton.XpButton cmdRestore
Height = 495
Left = 1320
TabIndex = 2
Top = 2040
Width = 1335
_ExtentX = 2355
_ExtentY = 873
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "還原(&R)"
PictureSmoothBackColor= 15460844
ButtonPicture = "FrmRestore.frx":08CA
End
Begin SmartXPButton.XpButton cmdExit
Cancel = -1 'True
Height = 495
Left = 2880
TabIndex = 3
Top = 2040
Width = 1335
_ExtentX = 2355
_ExtentY = 873
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "關閉(&E)"
PictureSmoothBackColor= 15460844
ButtonPicture = "FrmRestore.frx":0C64
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "請選擇備份文件,然后單擊“還原”按鈕,即可還原數(shù)據(jù)庫。"
Height = 660
Left = 240
TabIndex = 4
Top = 120
Width = 3420
End
End
Attribute VB_Name = "FrmRestore"
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 ret As Long '返回值
Dim buff As String
Private Sub Check1_Click()
buff = String(255, 0)
ret = GetPrivateProfileString("BackUp", "Restore", "", buff, 256, App.Path & "\Sims.ini")
If ret = 0 Then
MsgBox "你無權執(zhí)行還原數(shù)據(jù)庫的操作,請與管理員聯(lián)系!", vbOKOnly + vbInformation, "還原數(shù)據(jù)庫"
Unload Me
Exit Sub
End If
If Check1.Value = 1 Then
buff = String(255, 0)
ret = GetPrivateProfileString("BackUp", "NewFile", "", buff, 256, App.Path & "\Sims.ini")
If ret <> 0 Then cboFile.Text = buff
Else
cboFile.Text = ""
End If
End Sub
Private Sub cmdExit_Click()
success = WritePrivateProfileString("BackUp", "Restore", "", App.Path & "\Sims.ini")
Unload Me
End Sub
Private Sub cmdRestore_Click()
On Error GoTo err1
buff = String(255, 0)
ret = GetPrivateProfileString("BackUp", "Restore", "", buff, 256, App.Path & "\Sims.ini")
If ret = 0 Then
MsgBox "你無權執(zhí)行還原數(shù)據(jù)庫的操作,請與管理員聯(lián)系!", vbOKOnly + vbInformation, "還原數(shù)據(jù)庫"
Unload Me
Exit Sub
End If
If cboFile.Text <> "" Then
cn.Execute ("use master")
cn.Execute "restore database [Sims_four] from disk='" & App.Path & "\BackUP\" & cboFile.Text & "'"
MsgBox "數(shù)據(jù)庫還原成功!", vbOKOnly + vbInformation, "還原數(shù)據(jù)庫"
cboFile.Text = ""
Check1.Value = 0
Else
MsgBox "請選擇備份文件!", vbOKOnly + vbInformation, "還原數(shù)據(jù)庫"
End If
Exit Sub
err1:
If Err = -2147217900 Then
MsgBox "找不到指定的備份文件。" & vbCrLf & vbCrLf & "數(shù)據(jù)庫還原失敗!", vbOKOnly + vbInformation, "還原數(shù)據(jù)庫"
cboFile.Text = ""
Check1.Value = 0
Else
MsgBox "未知錯誤,數(shù)據(jù)庫還原失敗!", vbOKOnly + vbInformation, "還原數(shù)據(jù)庫"
End If
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
With cn
.ConnectionTimeout = 10
.Provider = "sqloledb"
.ConnectionString = "data source=.;initial catalog=master;user id=sa;password=;"
.Open
End With
'******把備份文件名加入列表框*******
buff = String(255, 0)
ret = GetPrivateProfileString("BackUp", "File1", "", buff, 256, App.Path & "\Sims.ini")
If ret <> 0 Then cboFile.AddItem buff
ret = GetPrivateProfileString("BackUp", "File2", "", buff, 256, App.Path & "\Sims.ini")
If ret <> 0 Then cboFile.AddItem buff
ret = GetPrivateProfileString("BackUp", "File3", "", buff, 256, App.Path & "\Sims.ini")
If ret <> 0 Then cboFile.AddItem buff
ret = GetPrivateProfileString("BackUp", "File4", "", buff, 256, App.Path & "\Sims.ini")
If ret <> 0 Then cboFile.AddItem buff
ret = GetPrivateProfileString("BackUp", "File5", "", buff, 256, App.Path & "\Sims.ini")
If ret <> 0 Then cboFile.AddItem buff
buff = String(255, 0)
ret = GetPrivateProfileString("BackUp", "NewFile", "", buff, 256, App.Path & "\Sims.ini")
If ret = 0 Then
Check1.Enabled = False
Else
Check1.Enabled = True
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
success = WritePrivateProfileString("BackUp", "Restore", "", App.Path & "\Sims.ini")
End Sub
Private Sub Form_Terminate()
If cn.State = adStateOpen Then cn.Close
Set cn = Nothing
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -