{ //ServerConnection connection = new ServerConnection(server='MRC-9';uid='sa';password='123456';multipleactiveresultsets=false); //To Avoid TimeOut Exception // Server sqlServer = new Server(connection); Restore res = new Restore(); //this.Cursor = Cursors.WaitCursor; //this.dataGridView1.DataSource = string.Empty; try { string fileName = @"\\MRC-9\E\Power_Management.bak"; string databaseName = "Power_Management"; res.Database = databaseName; res.Action = RestoreActionType.Database; res.Devices.AddDevice(fileName, DeviceType.File); this.progressBar1.Value = 0; this.progressBar1.Maximum = 100; this.progressBar1.Value = 10; res.PercentCompleteNotification = 10; res.ReplaceDatabase = true; res.PercentComplete += new PercentCompleteEventHandler(ProgressEventHandler); res.SqlRestore(srv); MessageBox.Show("Restore of " + databaseName + " Complete!", "Restore", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (SmoException exSMO) { MessageBox.Show(exSMO.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } //RestoreDatabase("Power_Management", "sa", "123456", "MRC-9", fileName); }
srv
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)