Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Backing up SQL Server
Message
 
 
À
16/03/2010 18:18:51
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01454971
Message ID:
01454973
Vues:
48
>This is a standard procedure I am using to backup a SQL Server database:
>
>
>    Public Function Backup() As Boolean
>        Dim loBackup As Backup = New Backup
>        Dim loServer As Server = New Server
>
>        oOriginator.Status.Text = "Backing up database..."
>
>        loBackup.Devices.AddDevice("D:\Data\Optic.bak", DeviceType.File)
>        loBackup.Database = "Optic"
>        loBackup.Action = Microsoft.SqlServer.Management.Smo.BackupActionType.Database
>        loBackup.Initialize = True
>        loBackup.PercentCompleteNotification = 1
>        AddHandler loBackup.PercentComplete, AddressOf ProgressEventHandler
>        loBackup.SqlBackup(loServer)
>
>        Return True
>    End Function
>
>    Private Sub ProgressEventHandler(ByVal sender As Object, ByVal e As PercentCompleteEventArgs)
>        oOriginator.Status.Text = "Backing up database: " + e.Percent.ToString + "% completed..."
>        Application.DoEvents()
>    End Sub
>
>
>Basically, to adapt it to a new environment, I simply change the loBackup.Devices.AddDevice line with the path and database name I wish to have and the loBackup.Database line to specify the database. However, in one particular environment, this code doesn't work. The error says that the backup failed. There is no more information. That server is SQL Server 2008, such as many other servers I have run this procedure into. Once I installed the SMO objects to be able to manipulate that remotely, I was able to have the code to execute up until the loBackup.SqlBackup(loServer). Does anyone know what kind of setting locally would affect it so it woudn't work?

Did you try to put loBackup.SqlBackup(loServer) into try/catch and examine the exception message ?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform