请教:关于备份和恢复的问题
备份文件代码如下:
Dim oSQLServer As New SQLDMO.SQLServer
Dim bkps As Object
oSQLServer.LoginSecure = False
oSQLServer.Connect("hnnc-44", "sa", "mike689")
Me.Cursor = Windows.Forms.Cursors.WaitCursor
bkps = CreateObject("SQLDMO.Backup")
BKPS.Database = "wage" '指定需备份的数据库
bkps.Action = 0
bkps.Files = "e:\wage.bak"
bkps.Initialize = True
Me.Cursor = Windows.Forms.Cursors.Default()
Application.DoEvents()
Dim mouseCur As Cursor
Me.Cursor = Windows.Forms.Cursors.WaitCursor
bkps.SQLBackup(oSQLServer)
Application.DoEvents()
bkps = Nothing
Me.Cursor = Windows.Forms.Cursors.Default()
MsgBox("数据备份完成", MsgBoxStyle.Information, "系统消息")
oSQLServer.DisConnect()
用单击按钮事件触发,这个是正常的
接下来的恢复文件:
Dim oSQLServer As New SQLDMO.SQLServer
Dim bkps As Object
oSQLServer.LoginSecure = False
oSQLServer.Connect("hnnc-44", "sa", "mike689")
Me.Cursor = Windows.Forms.Cursors.WaitCursor
bkps = CreateObject("SQLDMO.restore")
bkps.Database = "wage" '指定需恢复的数据库
bkps.Action = 0
'bkps.devices = "e:\"
bkps.Files = "e:\wage.bak"
bkps.ReplaceDatabase = True '!!!!!!
'bkps.FileNumber = 1
'Me.Cursor = Windows.Forms.Cursors.Default()
'Application.DoEvents()
'Dim mouseCur As Cursor
'Me.Cursor = Windows.Forms.Cursors.WaitCursor
bkps.SQLRestore(oSQLServer)
Application.DoEvents()
bkps = Nothing
Me.Cursor = Windows.Forms.Cursors.Default()
MsgBox("数据恢复完成", MsgBoxStyle.Information, "系统消息")
oSQLServer.DisConnect()
这个是用另外一个按钮事件触发,不能执行,系统的中断在“bkps.SQLRestore(oSQLServer)”这句上
另外我使用了backup database wage to disk='e:\wage.bak'是可以备份的
但是restore database wage from disk='e:\wage.bak'又不行
想不通,为什么同样的句型,都是只能备份不能恢复呢??