Restore sqlRestore = new Restore(); BackupDeviceItem deviceItem = new BackupDeviceItem(dataFilePath + "\\" + databaseName + ".bak", DeviceType.File); sqlRestore.Devices.Add(deviceItem); sqlRestore.Database = databaseName; ServerConnection connection = new ServerConnection(serverName); connection.LoginSecure = false; connection.Login = "gjgjg"; connection.Password = "ytryr"; Server sqlServer = new Server(connection); sqlRestore.Action = RestoreActionType.Database; String dataFileLocation = dataFilePath + "\\" + databaseName + ".mdf"; String logFileLocation = dataFilePath + "\\" + databaseName + "_log.ldf"; //System.Data.DataTable logicalRestoreFiles = sqlRestore.ReadFileList(sqlServer); //sqlRestore.RelocateFiles.Add(new RelocateFile(logicalRestoreFiles.Rows[0][0].ToString(),dataFileLocation)); //sqlRestore.RelocateFiles.Add(new RelocateFile(logicalRestoreFiles.Rows[1][0].ToString(),logFileLocation)); sqlRestore.ReplaceDatabase = false; //sqlRestore.Complete += new ServerMessageEventHandler(sqlRestore_Complete); sqlRestore.PercentCompleteNotification = 10; //sqlRestore.PercentComplete += new PercentCompleteEventHandler(sqlRestore_PercentComplete); sqlRestore.SqlRestore(sqlServer);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)