Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Backing up SQL Server
Message
From
16/03/2010 18:18:51
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Backing up SQL Server
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:
01454971
Views:
98
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?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform