Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows .NET4
Hello,
 
My backup file in C:\DatabaseBackup\ABC.bak, I am restoring database from this backup file.It's showing the error only in windows 7.
 
I have a windows service for database restore but it's not running successfully, it's showing the error.
 
How will be solved this problem?
Please help me urgently.
 
Start Service
Error: Microsoft.SqlServer.Management.Smo.FailedOperationException: Restore failed for Server 'USER-PC\SQLEXPRESS'.  ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Data.SqlClient.SqlException: User does not have permission to RESTORE database 'ABC'.
RESTORE DATABASE is terminating abnormally.
   at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
   at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
   --- End of inner exception stack trace ---
   at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
   at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
   at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
   at Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCollection queries)
   at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
   --- End of inner exception stack trace ---
   at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
   at DownloadDatabaseService.DBRestore.RestoreDatabase(String backupFile)
   at DownloadDatabaseService.DBRestore.OnElapsedTime(Object source, ElapsedEventArgs e)
 
Please help me urgently.
 
Thank You.
Ankit Agarwal
Software Engineer
Posted 10-Feb-13 22:44pm
Edited 10-Feb-13 22:53pm
Maciej Los142.7K
v2
Comments
Maciej Los at 11-Feb-13 4:56am
   
Do you use custom software or SSMS?
What kind of version of Win7 (32 or 64 bit)?
What kind of version of MS SQL Server (2k5, 2k8, 2012)?
ankit.agg1984 at 11-Feb-13 5:01am
   
Windows 7 64-Bit
SQL SERVER 2008
Guirec Le Bars at 11-Feb-13 5:30am
   
Just an idea... Create a user in the destination machine with the same login as the one who was 'owning' the backed-up database...

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

From the error message you have given it shows the user credentials under which the service is running does not have the permission to restore the permission.
So please ensure that this user has the sufficient privileges to restore a database on the SQLServer instance that you are connecting to.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100