Hi,
I'd like to know if I can monitor all the jobs in SQL Server 2000 or 2005 using SMO Objects. Specifically, I'd like to know if the jobs has been run, executed suceefully or not (recording to Log files). I also like to view/enumerate all the existing jobs. I'd like to know if all these are possible if I use SMO Object with Visual Basic.net.. If possible please give me sample code or web site so I can learn how to do it. Thanks for reading my post.
The method you'll want to look at is the EnumJobHistory method of the JobServer object. This method returns a DataTable, which you can bind to a DataGrid and see the results. You'll need to import Microsoft.SqlServer.Management.SMO.Agent as well as the .SMO and .Common namespaces.
Dim tblServerJobHist As DataTable
' Connect to the server
Dim srvMgmtServer As Server
srvMgmtServer = New Server("MyServer")
Dim srvConn As ServerConnection
srvConn = srvMgmtServer.ConnectionContext
srvConn.LoginSecure = True
tblServerJobHist = srvMgmtServer.JobServer.EnumJobHistory
Hope that helps you get started.
|||Thanks for reply my post. Furthermore, can i monitor the jobs that has been run successfully or not by using SMO object? for example, i like to have the SMO object to tell me if the jobs has run successfully or failed after a certain period.
Thanks.
|||You don't need SMO to notify you if a job has failed, because you can set up the job to send you notifications if that's what you need.|||Hi folksNow I have SQL Server 2000 & Visual Studio 2003
How can i Import this NameSpace "Microsoft.SqlServer.Management.SMO.Agent as well as the .SMO and .Common namespaces." which Reference i want to add this?
If its Not possible than How can i run this program in VB.NET 2003 or VB6.0 Please Help me... Its Very Urgent for me......
|||You can't use SMO with Visual Studio 2003, it is only available using Visual Studio 2005 or later. The SMO namespaces are only available in Visual Studio 2005.
No comments:
Post a Comment