Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chatravin
Starting Member
4 Posts |
Posted - 2006-10-25 : 13:39:43
|
I have a problem with restoring database using sqldmo that is SqlDmo.Restore can't restore backup files whose directory address includes a folder name with one or more blank. It just works well with other directory address. I've tried the same appraoch in SMO and again it didn't work. I'd be gratefull if anyone helpd me. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-10-25 : 14:56:38
|
Surround the path with double quotes.Tara Kizer |
 |
|
chatravin
Starting Member
4 Posts |
Posted - 2006-10-25 : 15:37:27
|
hi tkzer. thanks for your replyBut I don't understand it.I've surrounded the path with double quotes as following, do you mean I should add another double quotes or something else?BackupPath = @"G:\Programing\NewFolder\BodyBuilding.bac"; SQLDMO.SQLServer srv = new SQLDMO.SQLServer(); srv.LoginSecure = true; srv.Connect("(local)", "", ""); SQLDMO.Restore res = new SQLDMO.RestoreClass(); res.Devices = res.Files; res.Files = BackupPath; res.Database = PreInitialCatalog; res.ReplaceDatabase = true; res.SQLRestore(srv); |
 |
|
chatravin
Starting Member
4 Posts |
Posted - 2006-10-25 : 16:05:34
|
any way thanks for your caution,I used SMO objects instead of SQLDMO and the problem got solved. here's the code://using statement:using Microsoft.SqlServer.Management.Smo;using Microsoft.SqlServer.Management.Common;// Restore opertation: ServerConnection srvCon = new ServerConnection(cn); Server srv = new Server(srvCon); Microsoft.SqlServer.Management.Smo.Restore res = new Microsoft.SqlServer.Management.Smo.Restore(); res.Database = "BodyBuilding"; res.Action = RestoreActionType.Database; res.Devices.AddDevice(BackupPath, DeviceType.File); res.ReplaceDatabase = true; res.SqlRestore(srv); |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-10-25 : 16:16:49
|
The double quotes in your code are there for you to set the variable, not to deal with the spaces. In order to have spaces, you'd need to double them up or perhaps use single quotes around the path.Tara Kizer |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-10-26 : 01:12:01
|
SMO is preferred anyway. DMO is deprecated and won't be supported in the next release.SqlSpec - a fast, cheap, and comprehensive data dictionary generator for SQL Server 2000 and 2005 - http://www.elsasoft.org |
 |
|
|
|
|