Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Backing up SQL Server
Message
 
 
To
16/03/2010 18:18:51
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01454971
Message ID:
01454973
Views:
47
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform