Backup failed on VISTA but successfully run on XP
-
hi all, i use following procedure for backup of a database
Private Sub BackupDatabaseUsinSMO(ByVal DatabaseName As String, ByVal UserName As String, ByVal Password As String, ByVal ServerName As String, ByVal DestinationPath As String) Dim conn As ServerConnection = New ServerConnection(ServerName, UserName, Password) Dim myServer As Server = New Server(conn) Dim backup As Backup = New Backup backup.Action = BackupActionType.Database backup.Database = DatabaseName DestinationPath = System.IO.Path.Combine(DestinationPath, DatabaseName + ".bak") backup.Devices.Add(New BackupDeviceItem(DestinationPath, DeviceType.File)) backup.Initialize = True backup.Checksum = True backup.ContinueAfterError = True backup.Incremental = False backup.LogTruncation = BackupTruncateLogType.Truncate backup.SqlBackup(myServer) End Sub
above code works well on XP OS but when i run this code on VISTA machine then it give error"Backup failed for Server 'Machine\Instance'."
Inner Exception is{"An exception occurred while executing a Transact-SQL statement or batch."}
anybody have idea that how can i perform BackUp and Restore operation on VISTA .I use SQL Server 2005 Express edition -
hi all, i use following procedure for backup of a database
Private Sub BackupDatabaseUsinSMO(ByVal DatabaseName As String, ByVal UserName As String, ByVal Password As String, ByVal ServerName As String, ByVal DestinationPath As String) Dim conn As ServerConnection = New ServerConnection(ServerName, UserName, Password) Dim myServer As Server = New Server(conn) Dim backup As Backup = New Backup backup.Action = BackupActionType.Database backup.Database = DatabaseName DestinationPath = System.IO.Path.Combine(DestinationPath, DatabaseName + ".bak") backup.Devices.Add(New BackupDeviceItem(DestinationPath, DeviceType.File)) backup.Initialize = True backup.Checksum = True backup.ContinueAfterError = True backup.Incremental = False backup.LogTruncation = BackupTruncateLogType.Truncate backup.SqlBackup(myServer) End Sub
above code works well on XP OS but when i run this code on VISTA machine then it give error"Backup failed for Server 'Machine\Instance'."
Inner Exception is{"An exception occurred while executing a Transact-SQL statement or batch."}
anybody have idea that how can i perform BackUp and Restore operation on VISTA .I use SQL Server 2005 Express editionIt makes no difference for SQL SMO whether it's XP or Vista. I'd hazard a guess that in the server with Vista, SQL Server does not have enough permission to write into the backup folder. But as I said, this is just a guess.
-
It makes no difference for SQL SMO whether it's XP or Vista. I'd hazard a guess that in the server with Vista, SQL Server does not have enough permission to write into the backup folder. But as I said, this is just a guess.
i use same Server (SQL Server 2005 Express) for both OS . User is same since i use following procedure to install SQL Server,attach database and create login and User
str = Application.StartupPath & "\SQLEXPR32\setup.exe /qb ADDLOCAL=ALL INSTANCENAME=" & InstanceName & " SECURITYMODE=SQL SAPWD=sapassword DISABLENETWORKPROTOCOLS=0 " Shell(str, AppWinStyle.Hide, True) System.Threading.Thread.Sleep(5000) Dim MainServer As Server = New Server(ComputerName & "\" & InstanceName) With MainServer.ConnectionContext .LoginSecure = True .ConnectionString = "Server=" & ComputerName & "\" & InstanceName & " ;Trusted_Connection=Yes" Try .Connect() Catch ex As Exception Application.Exit() End Try If MainServer.Databases.Contains(DatabaseName) Then Else Dim logstr As String Dim datastr As String datastr = Application.StartupPath & "\V.mdf" logstr = Application.StartupPath & "\V_log.ldf" 'Attach the database Dim sc As StringCollection sc = New StringCollection sc.Add(datastr) sc.Add(logstr) Try MainServer.AttachDatabase(DatabaseName, sc) Catch ex As Exception MsgBox(ex.Message.ToString) End Try End If If MainServer.Logins.Contains(LoginName) Then Else Dim NewLogin As Login = New Login(MainServer, LoginName) NewLogin.LoginType = LoginType.SqlLogin NewLogin.DefaultDatabase = DatabaseName NewLogin.Create(LoginPassword) Dim db As New Database db = MainServer.Databases(DatabaseName) Dim DBUser As User = New User(db, UserName) DBUser.UserType = UserType.SqlLogin DBUser.Login = LoginName DBUser.Create() DBUser.AddToRole("db_Owner") End If .Disconnect() End With
above code works fine on both OS (XP and VISTA)modified on Tuesday, August 12, 2008 3:23 AM