using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WinUpload
{
public partial class oRestore : Form
{
public oRestore()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog sfd = new OpenFileDialog();
sfd.Filter = "备份文件(*.bak)|*.bak";
if (sfd.ShowDialog() == DialogResult.OK)
{
textBox2.Text = sfd.FileName;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox2.Text == "")
{
MessageBox.Show("位置不能为空!", "提示");
}
else
{
DataCenter dc = new DataCenter();
SQLDMO.Restore oRestore = new SQLDMO.RestoreClass();
SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
try
{
dc.exepro();
oSQLServer.LoginSecure = false;
oSQLServer.Connect("WEIJIA", "hu", "hu");
oRestore.Action = SQLDMO.SQLDMO_RESTORE_TYPE.SQLDMORestore_Database;
oRestore.Database = dc.GetDataBaseName;
oRestore.Files = textBox2.Text.Trim();
oRestore.FileNumber = 1;
oRestore.ReplaceDatabase = true;
oRestore.SQLRestore(oSQLServer);
MessageBox.Show("还原成功!", "提示");
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
oSQLServer.DisConnect();
}
}
}
}
}