从其他计算机还原数据库 [英] Restore database from other computer

查看:72
本文介绍了从其他计算机还原数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在构建一个应用程序,它可以从sql server备份和恢复数据库,但是当我远程连接到其他计算机时它不起作用。

我想构建一个应用程序通过'conectionsString'从远程其他计算机恢复数据库从其他机器恢复数据库,如SMO中的定位备份文件表单



此代码从我的计算机恢复数据库,它没有当远程到其他计算机时

Hi everyone, i'm building an application, it can backup and restore database from sql server, but it doesn't work when i remote to other computer.
I want to built an application to remote other computer by 'conectionsString" to restore database from other machine such as "Locate Backup File" form in SMO

This code restore database from my computer, it doesn't when remote to other computer

private void btnRestore_Click(object sender, EventArgs e)
       {
           if (srvSql != null)
           {
               if (openBackupDialog.ShowDialog() == DialogResult.OK)
               {
                   Restore rstDatabase = new Restore();
                   rstDatabase.Action = RestoreActionType.Database;
                   rstDatabase.Database = cmbDatabase.SelectedItem.ToString();
                   BackupDeviceItem bkpDevice = new
                   BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);
                   rstDatabase.Devices.Add(bkpDevice);
                   rstDatabase.ReplaceDatabase = true;
                   rstDatabase.SqlRestore(srvSql);
               }
           }
           else
           {
               MessageBox.Show("A connection to a SQL server was not established.", "Not Connected to Server", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
           }

推荐答案

首先检查执行恢复时访问的SQL服务器实例:它必须是远程版本,而不是本地实例。仔细检查您的连接字符串,并确保远程服务器上的用户具有创建数据库所需的正确权限(毕竟这是恢复操作所涉及的)。
Start by checking which instance of SQL server you are accessing when you do the restore: it has to be the remote version, not your local instance. Check your connection string carefully, and make sure that your user on the remote server has the correct permissions needed to create databases (which is what a restore operation involves, after all).


这篇关于从其他计算机还原数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆