gpt4 book ai didi

c# - 如何在c#中使用smo从其他计算机恢复数据库

转载 作者:太空宇宙 更新时间:2023-11-03 15:44:56 25 4
gpt4 key购买 nike

如何在c#中使用smo从其他计算机恢复数据库?这是我的资源:

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

关于c# - 如何在c#中使用smo从其他计算机恢复数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28491795/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com