zoukankan      html  css  js  c++  java
  • 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();
                    }
                 
    }
            }

               }
    }

  • 相关阅读:
    【转】P2P通信原理与实现(C++)
    【转】P2P通信标准协议(二)之TURN
    【转】P2P之UDP穿透NAT的原理与实现
    【转】P2P的原理和常见的实现方式
    【转】linux中man使用技巧
    【转】go编译时,加入svn版本信息
    各种移动GPU压缩纹理的使用方法
    Unity贴图压缩格式设置
    关于U3D贴图格式压缩
    可能会导致.NET内存泄露的8种行为
  • 原文地址:https://www.cnblogs.com/hyd309/p/1182803.html
Copyright © 2011-2022 走看看