| Author |
Topic  |
|
|
sonalisb
Starting Member
India
2 Posts |
Posted - 08/05/2012 : 06:48:49
|
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
|
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?? |
 |
|
|
sunitabeck
Flowing Fount of Yak Knowledge
5152 Posts |
Posted - 08/06/2012 : 07:00:55
|
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 |
 |
|
|
sonalisb
Starting Member
India
2 Posts |
Posted - 08/09/2012 : 01:35:12
|
| yes i tried it on button click event |
 |
|
| |
Topic  |
|