Restore failed for Server '...\SQLEXPRESS'
-
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 UsingC# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」
-
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 UsingC# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」
There may be active uses on the db when you are trying to restore a backup..
-
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 UsingC# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」
-
There may be active uses on the db when you are trying to restore a backup..
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 = NothingC# コードMicrosoft End User 2000-2008 「「「「「「「「「「「「「「「「「「「「「「「「「「「「 The best things in life are free 」」」」」」」」」」」」」」」」」」」」」」」」」」」」
-
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:
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 」」」」」」」」」」」」」」」」」」」」」」」」」」」」