zoukankan      html  css  js  c++  java
  • VS2005 通过SMO(SQL Management Objects) 管理 数据库的作业 警报 备份 等任务

    1.安装SQLServer2005相关版本
    2.在VS2005的项目中加入SMO相关参考
    3.在VS2005的文件中 加入using
    4.通过SMO相关类 进行对SQLServer的操作
    -----
    1.安装SQLServer2005相关版本
      以便能在 如下位置
      C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies
      得到相关 dll
      Microsoft.SqlServer.Smo.dll
      Microsoft.SqlServer.ConnectionInfo.dll
      ......
     
    2.在VS2005的项目中加入SMO相关参考
      项目-右键-添加引用(参考)
     
    3.在VS2005的文件中 加入using
    using Microsoft.SqlServer.Management.Smo;
    using Microsoft.SqlServer.Management.Common;

    using Microsoft.SqlServer.Management.Smo.Agent;
    using Microsoft.SqlServer.Management.Smo.Broker;
    其中还有其他一些空间 可以根据需要进行引用
    using Microsoft.SqlServer.Management.Smo.CoreEnum;
    using Microsoft.SqlServer.Management.Smo.Internal;
    using Microsoft.SqlServer.Management.Smo.Mail;
    using Microsoft.SqlServer.Management.Smo.RegisteredServers;
    using Microsoft.SqlServer.Management.Smo.SqlEnum;
    using Microsoft.SqlServer.Management.Smo.Wmi;

    4.通过SMO相关类 进行对SQLServer的操作
    示例代码如下:
    protected void Button1_Click(object sender, EventArgs e)
        {
            //myServer
            Server myServer = new Server("192.168.0.36");
            Job myJob = new Job();
            Job myJob11 = new Job();
            //
            if (!myServer.JobServer.Jobs.Contains("myJob1"))
            {
                myJob = new Job(myServer.JobServer, "myJob1");
            }
            else
            {
                myJob11 = myServer.JobServer.Jobs["myJob1"];
                Random a = new Random();
                myJob = new Job(myServer.JobServer,"myJob"+a.Next().ToString());           
            }

            myJob.Description = "aaa";

            if (myJob.State.ToString() != "Existing")
            {
                myJob.Create();
            }
            Response.Write(myJob.State.ToString());
            Response.Write(myJob11.Name.ToString());       
        }

  • 相关阅读:
    netstat -ano 查看机器端口占用情况
    配置中心Nacos 20210908
    ABAP-查询系统表记录
    ABAP-自定义表维护程序
    linux 常用操作
    自动化回归测试实战
    LeetCode大部分是medium难度不怎么按顺序题解(下)
    bitmapCache.getDataURL is not a function BUG修复
    createjs 刮刮卡,刮开百分比。 含源文件
    【nim语言】nim语言 1.4.8编译时SSL报错“No SSL/TLS CA certificates found” 解决方法。
  • 原文地址:https://www.cnblogs.com/freeliver54/p/592390.html
Copyright © 2011-2022 走看看