Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Label1.Caption = Dir1.Path & "\" & File1.FileName '获得路径
End Sub
Private Sub ListView1_Click()
Label1.Caption = Dir1.Path & "\" & ListView1.SelectedItem '获得路径
End Sub
Private Sub CmdBackup_Click()
Dim S
If Option1.Value = True Then
'备份数据库
S = Dir1.Path & "\" & Date & ".BAK"
If Label1.Caption = S Then
MsgBox "数据备份卡已存在!"
Else
StrCnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Backup"
'数据备份语句
sql = "backup DATABASE XYGL TO disk='" & S & "'"
StrCnn.Execute (sql) '执行SQL语句
StrCnn.Close
MsgBox "数据库备份成功!"
key = Date & ".BAK"
Set itmX = ListView1.ListItems.Add(, , key, 1)
End If
End If
If Option2.Value = True Then
'恢复指定路径下的数据库
If File1.ListCount <> 0 Then
If Label1.Caption <> "" Then
StrCnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Backup"
'数据恢复语句
sql = "RESTORE DATABASE XYGL from disk='" & Label1.Caption & "'"
StrCnn.Execute (sql) '执行SQL语句!!!!!!这边可以设置
StrCnn.Close
MsgBox "数据库恢复成功!"
Else
MsgBox "请选择要恢复的数据备份卡!"
End If
Else
MsgBox "请选择要恢复的数据备份卡!"
End If
End If
End Sub
Private Sub CmdEnd_Click()
End
End Sub