Dim StrCnn As New Connection
Dim itmX As ListItem
Dim key, list, sql As String
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Option1.Value = True
Dir1_Change
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
ListView1.ListItems.Clear
If File1.ListCount <> 0 Then
a = 0
Do While File1.ListIndex < File1.ListCount - 1
File1.ListIndex = a
key = File1.FileName
Set itmX = ListView1.ListItems.Add(, , key, 1)
a = a + 1
Loop
End If
File1_click
End Sub
Private Sub Drive1_change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_click()
Label2.Caption = Dir1.Path & "\" & File1.FileName
End Sub
Private Sub ListView1_Click()
Label2.Caption = Dir1.Path & "\" & ListView1.SelectedItem
End Sub
Private Sub Command1_Click()
Dim s
If Option1.Value = True Then
s = Dir1.Path & "\" & Date & ".BAK"
If Label2.Caption = s Then
MsgBox " 資料備份卡已存在!"
Else
StrCnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Backup "
sql = "backup DATABASE FDCPGGL TO disk='" & s & "'"
StrCnn.Execute (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 Label2.Caption <> "" Then
StrCnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Backup "
sql = "RESTORE DATABASE FDCPGGL FROM disk='" & Label2.Caption & "'"
StrCnn.Execute (sql)
StrCnn.Close
MsgBox "資料庫恢復成功!"
Else
MsgBox "請選擇要恢復的資料備份卡!"
End If
Else
MsgBox "請選擇要恢復的資料備份卡!"
End If
End If
End Sub
uj5u.com熱心網友回復:
檔案Dir1.Path & "\" & Date & ".BAK"
不存在
uj5u.com熱心網友回復:
檔案目錄下是存在的這樣的檔案的uj5u.com熱心網友回復:
A)BACKUP DATABASE 是在服務端執行的,你本機的路徑是無效的。B)就算資料庫運行在本機,它的啟動用戶和你當前用戶是不一樣的,訪問目錄還存在權限問題,最好把目錄權設為 everyone 完全控制。
uj5u.com熱心網友回復:
s = Dir1.Path & "\" & "房地產評估管理系統資料庫" & ".mdf"我將上面這個地方改了后,備份成功了。
但恢復又不對,提示restore無法處理資料庫‘FDCPGGL’,因為它正由此會話使用。建議執行此操作時使用master資料庫。我就將這句改為 sql = "RESTORE DATABASE master FROM disk='" & Label2.Caption & "'"
但提示若要還原master資料庫,服務器必須以單用戶模式運行。
uj5u.com熱心網友回復:
'你配置的這個 Backup 資料源中,默認資料庫不要設為 FDCPGGL,而是要用其它資料庫(比如 master)'
StrCnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=Backup"
'否則連接后 FDCPGGL 正在使用,是不能做恢復的'
sql = "RESTORE DATABASE FDCPGGL FROM disk='" & Label2.Caption & "'"
uj5u.com熱心網友回復:
我按你說的弄后,沒有這個提示了,但是提示媒體集有2個媒體簇,但只提供了一個。必須提供所有成員。轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/73737.html
