SQL bak文件恢复无法正常工作...... [英] SQL bak file restoration not working...

查看:105
本文介绍了SQL bak文件恢复无法正常工作......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将(恢复)远程PC(Sql Server)上的bak文件恢复。该文件存储在远程PC本身。但代码不起作用。它甚至没有显示错误。请帮助我...

 {
// ServerConnection connection = new ServerConnection(server =''MRC-9''; UID = '' SA '';口令= '' 123456 ''; multipleactiveresultsets = FALSE);
//避免TimeOut异常
//服务器sqlServer =新服务器(连接);
Restore res = new Restore();

//this.Cursor = Cursors.WaitCursor;
//this.dataGridView1.DataSource = string.Empty;

尝试
{
string fileName = @\\ MRC-9 \ E \ Power_Management.bak;
string databaseName =Power_Management;

res.Database = databaseName;
res.Action = RestoreActionType.Database;
res.Devices.AddDevice(fileName,DeviceType.File);

this.progressBar1.Value = 0;
this.progressBar1.Maximum = 100;
this.progressBar1.Value = 10;

res.PercentCompleteNotification = 10;
res.ReplaceDatabase = true;
res.PercentComplete + = new PercentCompleteEventHandler(ProgressEventHandler);
res.SqlRestore(srv);

MessageBox.Show(Restore of+ databaseName +Complete!,Restore,MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(SmoException exSMO)
{
MessageBox.Show(exSMO.ToString());
}
catch(exception ex)
{
MessageBox.Show(ex.ToString());
}
// RestoreDatabase(Power_Management,sa,123456,MRC-9,fileName);
}

解决方案

使用C#和.NET 2.0进行SQL Server 2005数据库备份和还原 [ ^ ] [ ]





阅读这篇文章,这将帮助你..

I am trying to restore a bak file on(to) remote pc(Sql Server). The file is stored in the remote pc itself. but the code is not working. its not even showing an error.help me please...

{
            //ServerConnection connection = new ServerConnection(server=''MRC-9'';uid=''sa'';password=''123456'';multipleactiveresultsets=false);
            //To Avoid TimeOut Exception
           // Server sqlServer = new Server(connection);
           Restore res = new Restore();

            //this.Cursor = Cursors.WaitCursor;
            //this.dataGridView1.DataSource = string.Empty;

            try
           {
                string fileName = @"\\MRC-9\E\Power_Management.bak";
                string databaseName = "Power_Management";

                res.Database = databaseName;
                res.Action = RestoreActionType.Database;
                res.Devices.AddDevice(fileName, DeviceType.File);

                this.progressBar1.Value = 0;
                this.progressBar1.Maximum = 100;
                this.progressBar1.Value = 10;

                res.PercentCompleteNotification = 10;
                res.ReplaceDatabase = true;
                res.PercentComplete += new PercentCompleteEventHandler(ProgressEventHandler);
                res.SqlRestore(srv);

                MessageBox.Show("Restore of " + databaseName + " Complete!", "Restore", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (SmoException exSMO)
            {
                MessageBox.Show(exSMO.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
              //RestoreDatabase("Power_Management", "sa", "123456", "MRC-9", fileName);
        }

解决方案

SQL Server 2005 Database Backup and Restore using C# and .NET 2.0[^][]


Read this article this wil help you..


这篇关于SQL bak文件恢复无法正常工作......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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