Thanks in advance,
Front end : Visual Studio 2010.
Back end : SQL Server 2005/2008 and SQL 2012 express.
I have created a small application which takes SQL Server database backup on desired location it works fine with SQL Server 2005/2008 but in case of SQL Express 2012
it gives error backup Failed for the Server.
Question:
1). Can i take backup Using my application as Front end and SQL Server 2012
or any Express SQL version as back end.
2). Is it because of SQL Express
3). My smo dll reference is of SQL 2005 that's why it's not taking backup ,
because the Express version is 2012
Any Solution/Idea/Links will be highly appreciated.
Here is the code
Public Function BackUP() As Boolean
Try
Application.DoEvents()
Dim conn As New ServerConnection(gSrv, gDbUsrID, gDbUsrPass)
Application.DoEvents()
Dim oSQLServer As New Server(conn)
Application.DoEvents()
If My.Computer.FileSystem.DirectoryExists(txtPath.Text) = False Then
My.Computer.FileSystem.CreateDirectory(txtPath.Text)
End If
Dim OrigBackupPath As String = txtPath.Text
Application.DoEvents()
Dim bkDevItem As New BackupDeviceItem(txtPath.Text & "\DB_BACKUP.BAK", DeviceType.File)
Application.DoEvents()
With oBackup
.Action = BackupActionType.Database
.Database = "DbName"
.Devices.Add(bkDevItem)
.Initialize = True
.Checksum = True
.ContinueAfterError = True
.Incremental = False
.LogTruncation = BackupTruncateLogType.Truncate
Application.DoEvents()
.SqlBackup(oSQLServer)
Application.DoEvents()
Process.Start("explorer.exe", OrigBackupPath)
BackUP = True
End With
Return BackUP
Catch ex As Exception
MessageBox.Show(ex.Message, "*", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Function