簡體   English   中英

如何在S#中使用smo從其他計算機還原數據庫

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

如何使用smo從c#中的其他計算機還原數據庫? 這是我的資源:

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);
        }
    }

我想通過“ OpenFileDialog”遠程到其他計算機。

晚了,但也不太晚,請訪問此頁面http://www.mssqltips.com/tipprint.asp?tip=1849

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM