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. General Programming
  3. Visual Basic
  4. Restore failed for Server '...\SQLEXPRESS'

Restore failed for Server '...\SQLEXPRESS'

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasesql-serverhelpvisual-studio
5 Posts 3 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.
  • C Offline
    C Offline
    C Coudou
    wrote on last edited by
    #1

    hi everyone, I always got an error Restore failed for Server '...\SQLEXPRESS' I googled it already and bunch of result. but still, i can't solve it. Details: *windows xp *sql server 2005 using PCNAME\SQLEXPRESS, (windows authentication mode) *visual studio 2005 *filePath= C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\DBNAME.bak note: sometimes it goes successfully but sometimes got an error. please help! thanks in advance. here's the code

    Using cnn As New SqlConnection(constrSQL)
    cnn.Open()
    dbName = cnn.Database.ToString()
    cnn.ChangeDatabase("master")
    Dim sc As New ServerConnection(cnn)
    Dim sv As New Server(sc)
    ' Create backup device item for the backup
    filePath = Path.Combine(filePath, databaseName & ".bak")
    Dim bdi As New BackupDeviceItem(filePath, DeviceType.File)
    ' Create the restore object
    Dim resDB As New Restore()
    resDB.Database = dbName
    resDB.Action = RestoreActionType.Database
    resDB.ReplaceDatabase = True
    resDB.NoRecovery = False
    resDB.Devices.Add(bdi)
    resDB.PercentCompleteNotification = 10
    AddHandler resDB.PercentComplete, AddressOf ProgressEventHandler
    resDB.Database = dbName
    ' Restore the database
    Try
    resDB.SqlRestore(sv)
    sv.Refresh()
    sv = Nothing
    Catch ex As Exception
    log.Debug(ex.ToString)
    Throw (ex)
    End Try
    End Using

    C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

    P L 2 Replies Last reply
    0
    • C C Coudou

      hi everyone, I always got an error Restore failed for Server '...\SQLEXPRESS' I googled it already and bunch of result. but still, i can't solve it. Details: *windows xp *sql server 2005 using PCNAME\SQLEXPRESS, (windows authentication mode) *visual studio 2005 *filePath= C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\DBNAME.bak note: sometimes it goes successfully but sometimes got an error. please help! thanks in advance. here's the code

      Using cnn As New SqlConnection(constrSQL)
      cnn.Open()
      dbName = cnn.Database.ToString()
      cnn.ChangeDatabase("master")
      Dim sc As New ServerConnection(cnn)
      Dim sv As New Server(sc)
      ' Create backup device item for the backup
      filePath = Path.Combine(filePath, databaseName & ".bak")
      Dim bdi As New BackupDeviceItem(filePath, DeviceType.File)
      ' Create the restore object
      Dim resDB As New Restore()
      resDB.Database = dbName
      resDB.Action = RestoreActionType.Database
      resDB.ReplaceDatabase = True
      resDB.NoRecovery = False
      resDB.Devices.Add(bdi)
      resDB.PercentCompleteNotification = 10
      AddHandler resDB.PercentComplete, AddressOf ProgressEventHandler
      resDB.Database = dbName
      ' Restore the database
      Try
      resDB.SqlRestore(sv)
      sv.Refresh()
      sv = Nothing
      Catch ex As Exception
      log.Debug(ex.ToString)
      Throw (ex)
      End Try
      End Using

      C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

      P Offline
      P Offline
      Pradeep Shukla 0
      wrote on last edited by
      #2

      There may be active uses on the db when you are trying to restore a backup..

      C 1 Reply Last reply
      0
      • C C Coudou

        hi everyone, I always got an error Restore failed for Server '...\SQLEXPRESS' I googled it already and bunch of result. but still, i can't solve it. Details: *windows xp *sql server 2005 using PCNAME\SQLEXPRESS, (windows authentication mode) *visual studio 2005 *filePath= C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\DBNAME.bak note: sometimes it goes successfully but sometimes got an error. please help! thanks in advance. here's the code

        Using cnn As New SqlConnection(constrSQL)
        cnn.Open()
        dbName = cnn.Database.ToString()
        cnn.ChangeDatabase("master")
        Dim sc As New ServerConnection(cnn)
        Dim sv As New Server(sc)
        ' Create backup device item for the backup
        filePath = Path.Combine(filePath, databaseName & ".bak")
        Dim bdi As New BackupDeviceItem(filePath, DeviceType.File)
        ' Create the restore object
        Dim resDB As New Restore()
        resDB.Database = dbName
        resDB.Action = RestoreActionType.Database
        resDB.ReplaceDatabase = True
        resDB.NoRecovery = False
        resDB.Devices.Add(bdi)
        resDB.PercentCompleteNotification = 10
        AddHandler resDB.PercentComplete, AddressOf ProgressEventHandler
        resDB.Database = dbName
        ' Restore the database
        Try
        resDB.SqlRestore(sv)
        sv.Refresh()
        sv = Nothing
        Catch ex As Exception
        log.Debug(ex.ToString)
        Throw (ex)
        End Try
        End Using

        C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi, The post above is correct.

        C#Coudou wrote:

        note: sometimes it goes successfully but sometimes got an error.

        Next time, include the message of the error. It can be quite helpful.

        Bastard Programmer from Hell :suss:

        C 1 Reply Last reply
        0
        • P Pradeep Shukla 0

          There may be active uses on the db when you are trying to restore a backup..

          C Offline
          C Offline
          C Coudou
          wrote on last edited by
          #4

          thanks prdshukla i think no other users who use the db because its a local machine and only 1 user, and in the end of my code I set to nothing the server.

          resDB.SqlRestore(sv)
          sv.Refresh()
          sv = Nothing

          C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

          1 Reply Last reply
          0
          • L Lost User

            Hi, The post above is correct.

            C#Coudou wrote:

            note: sometimes it goes successfully but sometimes got an error.

            Next time, include the message of the error. It can be quite helpful.

            Bastard Programmer from Hell :suss:

            C Offline
            C Offline
            C Coudou
            wrote on last edited by
            #5

            thanks Eddy Vluggen

            Eddy Vluggen wrote:

            Next time, include the message of the error. It can be quite helpful.

            the subject itself of this post is error message of my program. but you gave me an idea what is the real error which is the inner exception, and i found out that some process are not close or dispose. so i added a kill process, and it goes smoothly and perfectly. thanks you very much.

            C# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」

            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