怎样使用SQLDMO进行数据库备份和恢复?请给源码或参考文章?谢谢。 ado+sql语句 就搞定了阿不过连接 时不要 指定 数据库,只要连接到 服务器就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 strConn = "driver={sql server};server=" & txtSrvName.Text & ";uid=" & txtUserName.Text & ";pwd=" & txtPwd.Text & ""conn.Open strConnstrsql = "BACKUP DATABASE " & txtDbName.Text & " TO DISK='C:\setup_sys\" & strDbName & "'"conn.Execute strsqlstrsql = "RESTORE DATABASE " & txtDbName.Text & " FROM DISK='D:\MSSQL7\BACKUP\" & strDbName & "'"conn.Execute strsql 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.BackupoBackup.Action = SQLDMOBackup_DatabaseoBackup.Database = "Northwind"oBackup.Devices = "[NorthDev1],[NorthDev2]"oBackup.BackupSetName = "Northwind_Full"oBackup.BackupSetDescription = "Full backup of Northwind sample."oBackup.SQLBackup oSQLServer如果你按照上述方法做好一个通用的过程把原代码给我看看!!我也是抄来的我不懂vb,[email protected]或[email protected] VB 函数传递 控件名的方法 VB获取分页怎么实现? VB如何遍历HTML对象Select的值 数据库求教高手: 如何生成字符表达式 关于Common Dialog控件的一个问题。 怎样用Winsock发送邮件附件?送100分,高手请帮忙,拜托! 再问响应键盘操作的问题 高手之问: 请问sql数据库中的datatime属性与vb中的text控件的哪个属性相匹配 vb中能进行数据库备份吗?数据库备份的方法怎么样? 如何解决vb的458错误?
conn.Open strConnstrsql = "BACKUP DATABASE " & txtDbName.Text & " TO DISK='C:\setup_sys\" & strDbName & "'"
conn.Execute strsqlstrsql = "RESTORE DATABASE " & txtDbName.Text & " FROM DISK='D:\MSSQL7\BACKUP\" & strDbName & "'"
conn.Execute strsql
恢复数据库:
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,
[email protected]或[email protected]