我正在使用以下函数来备份使用SMO的SQL Server数据库..但备份失败...我不知道,为什么它失败...任何帮助表示赞赏。SMO数据库备份
Private Sub BackupSqlDatabase()
Dim conn As New ServerConnection("MONO-PC\SQLEXPRESS") ' -- set SQL server connection given the server name, user name and password
Dim oSQLServer As New Server(conn) '--create the SMO server object using connection
Dim OrigBackupPath As String = oSQLServer.Information.MasterDBPath.Replace("\DATA", "C:\Backup\DB_BACKUP_NAME.BAK") ' -- set the path where backup file will be stored
Dim bkDevItem As New BackupDeviceItem(OrigBackupPath, DeviceType.File) ' -- create SMO.Backupdevice object
With oBackup ' Set the backup object property
.Action = BackupActionType.Database
.Database = "LIC.MDF"
.Devices.Add(bkDevItem)
.Initialize = True
.Checksum = True
.ContinueAfterError = True
.Incremental = False
.LogTruncation = BackupTruncateLogType.Truncate
.SqlBackup(oSQLServer) ' backup SQL database
End With
End Sub
您是否收到错误消息? – JNK 2012-01-13 16:15:41
备份失败..有点......我没有管理工作室安装在我的电脑......是否是备份失败的原因? – 2012-01-13 16:17:52
你不需要将连接设置为:'Dim conn As New ServerConnection(“MONO-PC \\ SQLEXPRESS”)'(两个反斜杠)? – 2012-01-13 16:18:18