[引用]SQL Server 2005 Books Online How to: Create a Job with Steps and a Schedule in Visual Basic .NET
来源:互联网 发布:淘宝虚拟试衣功能在哪 编辑:程序博客网 时间:2024/05/01 06:24
-
Start Visual Studio 2005.
-
From the File menu, select New Project. The New Project dialog box appears.
-
In the Project Types pane, select Visual Basic. In the Templates pane, select Console Application.
-
(Optional) In the Name box, type the name of the new application.
-
Click OK to load the Visual Basic console application template.
-
On the Project menu, select Add Reference item. The Add Reference dialog box appears. Select Browse and locate the SMO assemblies in the C:/Program Files/Microsoft SQL Server/90/SDK/Assemblies folder. Select the following files:
Imports Microsoft.SqlServer.Management.SMO
Imports Microsoft.SqlServer.Management.Common
Imports Microsoft.SqlServer.Management.SMO.AgentOn the View menu, click Code.-Or-Select the Form1.vb window to display the code window.
-
In the code, before any declarations, type the following Imports statements to qualify the types in the SMO namespace:
1'Connect to the local, default instance of SQL Server.
2Dim srv As Server
3srv = New Server
4'Define an Operator object variable by supplying the Agent (parent JobServer object) and the name in the constructor.
5Dim op As [Operator]
6op = New [Operator](srv.JobServer, "Test_Operator")
7'Set the Net send address.
8op.NetSendAddress = "Network1_PC"
9'Create the operator on the instance of SQL Server Agent.
10op.Create()
11'Define a Job object variable by supplying the Agent and the name arguments in the constructor and setting properties.
12Dim jb As Job
13jb = New Job(srv.JobServer, "Test_Job")
14'Specify which operator to inform and the completion action.
15jb.OperatorToNetSend = "Test_Operator"
16jb.NetSendLevel = CompletionAction.Always
17'Create the job on the instance of SQL Server Agent.
18jb.Create()
19'Define a JobStep object variable by supplying the parent job and name arguments in the constructor.
20Dim jbstp As JobStep
21jbstp = New JobStep(jb, "Test_Job_Step")
22jbstp.Command = "Test_StoredProc"
23jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess
24jbstp.OnFailAction = StepCompletionAction.QuitWithFailure
25'Create the job step on the instance of SQL Server Agent.
26jbstp.Create()
27'Define a JobSchedule object variable by supplying the parent job and name arguments in the constructor.
28Dim jbsch As JobSchedule
29jbsch = New JobSchedule(jb, "Test_Job_Schedule")
30'Set properties to define the schedule frequency and duration.
31jbsch.FrequencyTypes = FrequencyTypes.Daily
32jbsch.FrequencySubDayTypes = FrequencySubDayTypes.Minute
33jbsch.FrequencySubDayInterval = 30
34Dim ts1 As TimeSpan
35ts1 = New TimeSpan(9, 0, 0)
36jbsch.ActiveStartTimeOfDay = ts1
37Dim ts2 As TimeSpan
38ts2 = New TimeSpan(17, 0, 0)
39jbsch.ActiveEndTimeOfDay = ts2
40jbsch.FrequencyInterval = 1
41Dim d As Date
42d = New Date(2003, 1, 1)
43jbsch.ActiveStartDate = d
44'Create the job schedule on the instance of SQL Server Agent.
45jbsch.Create()
- [引用]SQL Server 2005 Books Online How to: Create a Job with Steps and a Schedule in Visual Basic .NET
- HOW TO: Upload a File to a Web Server in ASP.NET by Using Visual Basic .NET
- How to create a Plone Blog in 5 steps
- How to create a function in SQL
- How to read and save Images in a Sql Server Database using ADO.NET and C#
- How to create a DLL library in C and then use it with C#
- How to create a PictureMarkerSymbol (Picture Symbol)in ArcGIS server with C#
- How to create a PictureMarkerSymbol (Picture Symbol)in ArcGIS server with C#
- How to create a File-Compare function in Visual C#
- "HOW TO: Create a Smooth Progress Bar in Visual C# .NET"的学习笔记
- How to debug a Visual Studio .NET 2005 Add-In
- How to create and apply a patch with git
- How to create and apply a patch with Git
- How to Create a Slick and Clean Button in Photoshop
- How to create (and deploy) a windows service in C# ?
- How To Create A Socket Based iPhone App and Server
- How to Create a Second Level GridView in ASP.NET
- Building a Basic Flash MX Page with ASP.NET and SQL Server
- 自定义日历控件
- 常用的JS与XML结合用法 简单示例
- SQL2000 和 SQL2005 下 行列转换 示例
- SQL 2005 Express 的“企业管理器” 下载
- VS2005 安装项目 需要学习
- [引用]SQL Server 2005 Books Online How to: Create a Job with Steps and a Schedule in Visual Basic .NET
- VS2005 通过SMO(SQL Management Objects) 管理 数据库的作业 警报 备份 等任务
- 自定义控件的 Enum类和Color类 属性的公开设定
- 正则表达式 验证 ****年**月
- VS2005 XML注释生成XML文档文件
- 浏览器兼容
- 得到内网可用的SqlServer 及某数据库下的表及其他的架构
- Duwamish示例下载
- 华表 单元格公式设定与计算