Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Backup failed on VISTA but successfully run on XP

Backup failed on VISTA but successfully run on XP

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sunil goyalG
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • S sunil goyalG

      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

      S Offline
      S Offline
      SimulationofSai
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • S SimulationofSai

        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.

        S Offline
        S Offline
        sunil goyalG
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups