I want to restore a database in C # using ASP.NET web application. Can you help with that?
You must use the following namespaces
Microsoft.SqlServer.Management Using SMO; Using Microsoft.SqlServer.Management.Common; Public Bull Restore DB (string DBN name, string backup path, string new location, string username, password) {ServerConnection con =
New ServerConnection (serverName)); If (user name == "") con.LoginSecure = true; Other {con.LoginSecure = false; Con.login = userName; Con.password = password; Restore restore = obj = new restore (); Var srv = new server (conn); If (srv! = Null) {restoreObj.Action = RestoreActionType.Database; RestoreObj.Database = dbName; BackupDeviceItem resDevice = new backup device item (Backup Path, DeviceType.File); Restore obz. Fullcomplete Notifications = 10; RestoreObj.ReplaceDatabase = false; RestoreObj.Devices.Add (resDevice); RestoreObj.PercentComplete + = (Sender, evtargs) = & gt; {// on progress callback}; RestoreObj.Complete + = (Sender, evtargs) = & gt; {// on competing callback}; RestoreObj.SqlRestoreAsync (SRV); } Back true; }
Comments
Post a Comment