Thursday, August 4, 2011

Create Backup file for Sql server database

The easy VB.NET function used to take backup of sql server database.


'Reference added

Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common


'Declare the backup object

Dim WithEvents oBackup As New Backup


'Method to take backup


Private Sub BackupSqlDatabase()


'set SQL server connection given the server name, user name and password

Dim conn As New ServerConnection(serverName, userName, passWd)

'create the SMO server object using connection

Dim oSQLServer As New Server(conn)

'set the path where backup file will be stored

Dim OrigBackupPath As String = oSQLServer.Information.MasterDBPath.Replace("\DATA", "\Backup\DB_BACKUP_NAME.BAK")


'create SMO.Backupdevice object

Dim bkDevItem As New BackupDeviceItem(OrigBackupPath, DeviceType.File)

' Set the backup object property

With oBackup
.Action = BackupActionType.Database
.Database = YOUR_DATABASE_NAME
.Devices.Add(bkDevItem)
.Initialize = True
.Checksum = True
.ContinueAfterError = True
.Incremental = False
.LogTruncation = BackupTruncateLogType.Truncate

'backup SQL database

.SqlBackup(oSQLServer)
End With

End Sub


Your comment will be appreciated.

What is SharePoint?

Microsoft SharePoint is a web application that enables users within an organization to work together, collaborate, more efficiently through its vast number of features.

Although collaboration is at the heart of SharePoint, it includes many other important core features to help in the following business needs:
• Document Management
• Web Content Management
• Business Process Management (Workflows)
• Enterprise Search
• Business Intelligence (Dashboards, Reports)
• Electronic Forms (InfoPath)
• Social Networking
And that’s just out-of-the-box features. Not only can all these features be customized to fit any organization but SharePoint can also serve as a platform to build solutions (custom applications) for any type of organization or need.