简体   繁体   English

如何在S#中使用smo从其他计算机还原数据库

[英]How to use smo to restore database from other computer in c#

how to use smo to restore database from other computer in c#? 如何使用smo从c#中的其他计算机还原数据库? This is my resource: 这是我的资源:

private void btnrestore_Click(object sender, EventArgs e)
    {
        try
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (srv != null)
            {
                ofd.Title = "Restore BackUp...";
                ofd.Filter = "Backup File|*.bak";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    Restore re_db = new Restore();
                    re_db.Action = RestoreActionType.Database;
                    re_db.Database = cmbDatabase.SelectedItem.ToString();
                    BackupDeviceItem bk_item = new BackupDeviceItem(ofd.FileName, DeviceType.File);
                    re_db.Devices.Add(bk_item);
                    re_db.ReplaceDatabase = true;
                    re_db.SqlRestore(srv);
                }
            }
            else
            {
                MessageBox.Show("A connection to a SQL server was not established.", "Not Connected to Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

I want to remote to other computer by "OpenFileDialog". 我想通过“ OpenFileDialog”远程到其他计算机。

晚了,但也不太晚,请访问此页面http://www.mssqltips.com/tipprint.asp?tip=1849

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM