• 在C#中运用SQLDMO备份SQL Server数据库


    DMO由一个动态链接库SQLDMO.DLL文件(在C:\Program Files\Microsoft SQL Server\80\Tools\Binn目录下)

    using System;

    using System.Collections.Generic;

    using System.Text;

     

     

        class Program

        {

            static void Main(string[] args)

            {

                DbBackup();

                       

     

            }

     

             ///<summary>

         /// 数据库备份

         ///</summary>

         public static void DbBackup()

          {

               SQLDMO.Backup oBackup = new SQLDMO.BackupClass();

               SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();

               try

               {

                   oSQLServer.LoginSecure = false;

                   oSQLServer.Connect(@".\SQL2005", "sa", "123456");

                   Console.WriteLine("正在连接服务器");

                   oBackup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database;

                   oBackup.Database = "SMMM";

                   oBackup.Files = @"d:\SMMM.bak";

                   oBackup.BackupSetName = "SMMM";

                   oBackup.BackupSetDescription = "数据库备份";

                   oBackup.Initialize = true;

                   Console.WriteLine("正在备份");               

                   oBackup.SQLBackup(oSQLServer);

                   Console.WriteLine("备份完成");               

     

               }

               //catch

               // {

               //     throw;

               // }

               catch (Exception ex)

               {

                   Console.WriteLine(ex.Message);

               }

     

              finally

              {

                   oSQLServer.DisConnect();

              }

          }

        

    }

     

     

      

     

     

  • 相关阅读:
    事务的基本特性和隔离级别
    mysql锁的类型
    索引设计的原则
    mysql聚簇索引和非聚簇索引的区别
    spring事务什么时候会失效?
    spring事务传播机制
    GAN的Pytorch实现
    DCGAN的Pytorch实现
    PyTorch学习教程、手册
    去噪论文合集Paper
  • 原文地址:https://www.cnblogs.com/qanholas/p/2198287.html
Copyright © 2020-2023  润新知