Failed With The Operating System Error 2error Not Found. Microsoft.sqlserver.smo
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error restoring database backup up vote 11 down vote favorite 1 I am getting an error using SQL Server 2012 when restoring a backup made with a previous version (SQL Server 2008). I actually have several backup files of the same database (taken at different times in the past). The newest ones are restored without any problems; however, one of them gives the following error: System.Data.SqlClient.SqlError: Directory lookup for the file "C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\MYDB_ABC.MDF" failed with the operating system error 3(The system cannot find the path specified.). (Microsoft.SqlServer.SmoExtended) This is a x64 machine, and my database file(s) are in this location: c:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL. I do not understand why it tries to restore on MSSQL.1 and not MSSQL11.MSSQLSERVER. sql-server database exception-handling restore sql-server-2012 share|improve this question edited May 24 '12 at 17:15 marc_s 453k938651031 asked May 24 '12 at 16:11 Marius Bancila 11.3k62970 3 This has nothing to do with version problems. (The message tells you that) –usr May 24 '12 at 16:30 @marc_s, why do you people feel obliged to alter the questions? I could understand the bold, but not the title, the quote, the ending, etc. –Marius Bancila May 25 '12 at 6:46 @usr, I mentioned SQL Server 2012, because the problems does not occur on machines with SQL Serve 2008. So, I guess, there is a connection. –Marius Bancila May 25 '12 at 6:47 @MariusBancila: the system used belongs into the tags - not the title - that's what the tags are for. Path and table names etc. should be put between back quotes to make them stand out as such (bold isn't optimal for that). I was just trying to make your question look more like a well formatted question - but OK, if you don't like it - I'll try to never touch any of your questions anymore..... –marc_s May 25 '12 at 7:47 This answers below don't directly address the context Marius was working in (that of the SMO), using c# or powershell; these answers are work arounds, and using WITH MOVE eventually gets things
restoringthecontent Database backup(.bak) to newly createdcontent database in the database list, you will find this Error message. System.Data.SqlClient.SqlError Directory lookup for the file "Path" failed with the operating system error 2(error not found). (Microsoft.SqlServer.Express.Smo) Solution: To solve this problem, use the steps mentioned below. 1) Right click in the new database in the database list 2) Tasks --> Restore --> Database... 3)Select 'From device' option to browse the backup file location 4) Enable http://stackoverflow.com/questions/10741281/error-restoring-database-backup the Restore checkbox for DatabaseBackup and Transaction Log Backup in the selected backup path 5) Go to Options in the top left --> Select the Overwrite the existing database option 6) Most Important: Check the newly created Database Path which is selected properly or not as per in the below http://sandyssharepointsite.blogspot.com/2011/09/solved-systemdatasqlclientsqlerror.html mentioned screenshot. 7) Once you confirm with the database location, click OK to restore. Posted by Sandeep(Sandy) at 09:42 Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest 1 comment: Matthew Carnagey9 August 2014 at 22:11I was having this issue, and when I went to the path and followed it, I found that the database was trying to restore to C:\Program Files\..., and I needed to change it to C:\Program Files (x86)\.... This was necessary because I was moving the database from a 32-bit Server to a 64-bit Server.ReplyDeleteAdd commentLoad more... Newer Post Older Post Home Subscribe to: Post Comments (Atom) Followers Blog Archive ► 2016 (1) ► May (1) ► 2015 (4) ► December (1) ► October (1) ► July (2) ▼ 2011 (2) ▼ September (1) [Solved] System.Data.SqlClient.SqlError Directory ... ► July (1) About Me Sandeep(Sandy) View my complete profile Simple template. Powered by Blogger.
first visit, be sure to check out the FAQ by clicking the link above. You may have to register before http://www.dbforums.com/showthread.php?1640232-Restoring-SQL-2000-file-to-SQL-2005 you can post: click the register link above to proceed. To http://www.bigresource.com/MS_SQL-Error-in-my-code-during-restoring-with-SMO-YbVljWTP.html start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread: Restoring SQL 2000 file to SQL 2005 Tweet Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode failed with Switch to Hybrid Mode Switch to Threaded Mode 03-26-09,06:39 #1 nsdbiu View Profile View Forum Posts Registered User Join Date Mar 2009 Posts 4 Unanswered: Restoring SQL 2000 file to SQL 2005 Hi i have the back up of a SQL 2000 database and i tried to restore it on my SQL 2005 but i ran into this failed with the error TITLE: Microsoft SQL Server Management Studio ------------------------------ Restore failed for Server 'XP\SQLEXPRESS'. (Microsoft.SqlServer.Smo) For help, click: Source: ID: ( ) - Events And Errors Message Center: Message Details ------------------------------ ADDITIONAL INFORMATION: System.Data.SqlClient.SqlError: The operating system returned the error '5(error not found)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL.3\MSSQL\LMH.MDF'. (Microsoft.SqlServer.Smo) For help, click: http://go.microsoft.com/fwlink?ProdN...0&LinkId=20476 The steps i followed right clicked on databases--->restore database from device---> specified the path to the backup --> it dint appear bec the file dint have an extension and so i typed the name of the file--->ok selected the single entry in the backupsets to restore the name of the db LMH was displayed in the drop down for To Database--> seleceted that.. in the left pane in options selected the overwrite existing db--> ok and i got the error mentioned above.. please help Reply With Quote 03-26-09,09:50 #2 MCrowley View Profile View Forum Posts Registered User Join Date Jan 2003 Location Massachusetts Posts 5,794 Provided Answers: 11 Did you specify any option like "Overwrite existing da
SMO, now i want to restore it with the code below: [code] Private Sub RestoreDataBase(ByVal BackupFilePath As String, ByVal destinationDatabaseName As String, ByVal DatabaseFolder As String, ByVal DatabaseFileName As String, ByVal DatabaseLogFileName As String) Dim myServer As New Server(My.Settings.SQLServer) Dim myRestore As New Restore() myRestore.Database = destinationDatabaseName Dim currentDb As Database = myServer.Databases(destinationDatabaseName) If currentDb IsNot Nothing Then myServer.KillAllProcesses(destinationDatabaseName) End If myRestore.Devices.AddDevice(BackupFilePath, DeviceType.File) Dim DataFileLocation As String = DatabaseFolder + "" + destinationDatabaseName + ".mdf" Dim LogFileLocation As String = DatabaseFolder + "" + destinationDatabaseName + "_log.ldf" myRestore.RelocateFiles.Add(New RelocateFile(DatabaseFileName, DataFileLocation)) myRestore.RelocateFiles.Add(New RelocateFile(DatabaseLogFileName, LogFileLocation)) myRestore.ReplaceDatabase = True myRestore.PercentCompleteNotification = 7 AddHandler myRestore.PercentComplete, AddressOf PercentReturn Try myRestore.SqlRestore(myServer) currentDb = myServer.Databases(destinationDatabaseName) currentDb.SetOnline() Catch ex As Exception If ex.InnerException IsNot Nothing Then MessageBox.Show(ex.Message & vbCrLf & ex.InnerException.Message, "Ex + InnerEx", MessageBoxButtons.OK, MessageBoxIcon.Error) Else MessageBox.Show(ex.Message, "Ex", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Try End Sub [/code] When the program reaches the red line, he throws the following error: Restore failed for Server 'NB_DELL_JWOSQLEXPRESS'. System.Data.SqlClient.SqlError: Logical file 'TMP_MIXix_20080129.' is not part of database 'TMP_MIXix_20080129.'. Use RESTORE FILELISTONLY to list the logical file names. The originale databasename is MIXix and I take a complete backup of it using the code below (WORKS): [code] Sub BackupDB(ByVal Filename As String) Dim srv As New Server(My.Settings.SQLServer) Dim bk As New Backup Dim bdi As New BackupDeviceItem(Filename, DeviceType.File) bk.Action = BackupActionType.Database bk.BackupSetDescription = "Full backup of " & My.Settings.Catalog bk.BackupSetName = My.Settings.Catalog & " backup" bk.Database = My.Settings.Catalog bk.Devices.Add(bdi) bk.Incremental = False bk.ExpirationDate = Now.Date bk.LogTruncation = BackupTruncateLogType.Truncate AddHandler bk.PercentComplete, AddressOf PercentReturn bk.SqlBackup(srv) bk.Devices.Remove(bdi) bk = Nothing srv = Nothing GC.Collect() End Sub [/code] Does any