• WinForm 数据库还原


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace WinUpload
    {
        public partial class oRestore : Form
        {
            public oRestore()
            {
                InitializeComponent();
            }

            private void button3_Click(object sender, EventArgs e)
            {
                OpenFileDialog sfd = new OpenFileDialog();
                sfd.Filter = "备份文件(*.bak)|*.bak";
             
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    textBox2.Text = sfd.FileName;
                }
            }

            private void button1_Click(object sender, EventArgs e)
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("位置不能为空!", "提示");
                }
                else
                {
                    DataCenter dc = new DataCenter();

                    SQLDMO.Restore oRestore = new SQLDMO.RestoreClass();
                    SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
                    try
                    {                  
                        dc.exepro();
                        oSQLServer.LoginSecure = false;
                        oSQLServer.Connect("WEIJIA", "hu", "hu");
                        oRestore.Action = SQLDMO.SQLDMO_RESTORE_TYPE.SQLDMORestore_Database;
                        oRestore.Database = dc.GetDataBaseName;
                        oRestore.Files = textBox2.Text.Trim();
                        oRestore.FileNumber = 1;
                        oRestore.ReplaceDatabase = true;
                        oRestore.SQLRestore(oSQLServer);
                        MessageBox.Show("还原成功!", "提示");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "失败");
                    }

                    finally
                    {
                        oSQLServer.DisConnect();
                    }
                 
    }
            }

               }
    }

  • 相关阅读:
    图论分支-Tarjan初步-边双联通分量
    图论分支-Tarjan初步-割点和割边
    简谈图论重要性&&图论总结
    Angular本地数据存储LocalStorage
    (转)AngularJS中使用的表单验证
    (转)AngularJS判断checkbox/复选框是否选中并实时显示
    (转载)JavaScript世界万物诞生记
    (转载)关于My97 datepicker与Angular ng-model绑定问题解决。
    mysql
    mysql
  • 原文地址:https://www.cnblogs.com/hyd309/p/1182803.html
Copyright © 2020-2023  润新知