救急:关于数据库备份与恢复的问题?

xhzhang 2001-09-07 05:47:26
各位大侠,我下面的恢复程序有什么问题呢,请指点迷津?

Private Sub Command3_Click()
Dim sFile As String
Dim oServer As New SQLDMO.SQLServer
Dim oDatabase As New SQLDMO.Database
Dim oRestore As New SQLDMO.Restore
On Error GoTo SaveErr
oServer.Connect "zxh", "sa", ""
oRestore.Action = SQLDMORestore_Database
oRestore.Database = "netenv"

oRestore.Devices = "D:\mssql7\BACKUP\data010907.dat"
oRestore.FileNumber = 1
oRestore.Files = "D:\mssql7\BACKUP\data010907"
' oRestore.StandbyFiles = "D:\mssql7\BACKUP\data010907"
oRestore.ReplaceDatabase = True
oRestore.SQLRestore oServer
' With oRestore
'
' .Files = "data010907.dat"
'
' .Database = "netenv"
' .ReplaceDatabase = True
' .SQLRestore oServer
' End With

Set oRestore = Nothing
Set oDatabase = Nothing
oServer.DisConnect
Set oServer = Nothing
MsgBox ("OK")

Exit Sub
SaveErr:
End Sub
...全文
88 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjg751206 2001-11-26
  • 打赏
  • 举报
回复
SQL Server可以使用SQL-DMO来做:
恢复数据库:
Private Sub Command2_Click()
Dim sFile As String
sFile = "N_1"

Dim oServer As New SQLDMO.SQLServer
Dim oDatabase As New SQLDMO.Database
Dim oRestore As New SQLDMO.Restore

oServer.Connect servername, username, password
With oRestore

.Files = sFile

.Database = "Northwind"
.ReplaceDatabase = True
.SQLRestore oServer
End With

Set oRestore = Nothing
Set oDatabase = Nothing
oServer.DisConnect
Set oServer = Nothing
MsgBox ("OK")

End Sub

备份:
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Database
oBackup.Database = "Northwind"
oBackup.Devices = "[NorthDev1],[NorthDev2]"
oBackup.BackupSetName = "Northwind_Full"
oBackup.BackupSetDescription = "Full backup of Northwind sample."

oBackup.SQLBackup oSQLServer


如果你按照上述方法做好一个通用的过程把原代码给我看看!!
我也是抄来的我不懂vb,
zjg751206@sina.com.cn或zjgnj@263.net
xhzhang 2001-09-07
  • 打赏
  • 举报
回复
各位,帮帮忙啊。
Jneu 2001-09-07
  • 打赏
  • 举报
回复
要下班了。
xhzhang 2001-09-07
  • 打赏
  • 举报
回复
怎么没人在呢?

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧