SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Restore failed for Server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sonalisb
Starting Member

India
2 Posts

Posted - 08/05/2012 :  06:48:49  Show Profile  Reply with Quote
I am trying to restore database form .bak file by using code

ServerConnection connection = new ServerConnection(serverName, userName, password);
Server sqlServer = new Server(connection);
Restore rstDatabase = new Restore();
rstDatabase.Action = RestoreActionType.Database;
rstDatabase.Database = databaseName;
string path = "Nilkamaldb.bak";
BackupDeviceItem bkpDevice = new BackupDeviceItem(path, DeviceType.File);
rstDatabase.Devices.Add(bkpDevice);
rstDatabase.ReplaceDatabase = true;
rstDatabase.SqlRestore(sqlServer);



but it gives error Restore failed for Server '[\\.\pipe\8780CEAA-E40B-4F\tsql\query]'
i don't understand why it says??

ahmeds08
Constraint Violating Yak Guru

India
424 Posts

Posted - 08/06/2012 :  05:41:57  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
quote:
Originally posted by sonalisb

I am trying to restore database form .bak file by using code

ServerConnection connection = new ServerConnection(serverName, userName, password);
Server sqlServer = new Server(connection);
Restore rstDatabase = new Restore();
rstDatabase.Action = RestoreActionType.Database;
rstDatabase.Database = databaseName;
string path = "Nilkamaldb.bak";
BackupDeviceItem bkpDevice = new BackupDeviceItem(path, DeviceType.File);
rstDatabase.Devices.Add(bkpDevice);
rstDatabase.ReplaceDatabase = true;
rstDatabase.SqlRestore(sqlServer);



but it gives error Restore failed for Server '[\\.\pipe\8780CEAA-E40B-4F\tsql\query]'
i don't understand why it says??



Did you try restoring from GUI??
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 08/06/2012 :  07:00:55  Show Profile  Reply with Quote
Run it in Visual Studio debugger and look at the variables in the sqlServer object. It may be that the serverName variable has something other than what you expect.

If that does not help, start with the example on this page (which is restoring to a local drive), get that working, change one parameter at a time to match your requirements, testing each step of the way: http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.sqlrestore.aspx
Go to Top of Page

sonalisb
Starting Member

India
2 Posts

Posted - 08/09/2012 :  01:35:12  Show Profile  Reply with Quote
yes i tried it on button click event
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000