Solved

How to Run SQL Server job from VB

Posted on 2004-03-26
4
227 Views
Last Modified: 2010-05-01
I have a job scheduled to run daily at a specific time. But due to some reason, my users want to run it run it when they want to run it. So i want to give them the access to run the job from VB. How can i do it???
Pls help
0
Comment
Question by:GaneshkIyer2004
  • 2
4 Comments
 

Expert Comment

by:Retailigence
Comment Utility

You can simply start a jog using the "sp_start_job" SP.To run this you must have ur SQLAgent running on ur server.
Any way u can set it to start at the time of Windows is starting.Apply this Code and see.It will solv ur problem.Else u can
use SQL DMO to do this work.First try this and see.

Dim AdoCON As ADODB.Connection
Dim strSQL as String

With AdoCON

        strSQL = "USE <Your DatabaseName>"
        .Execute  strSQL
        strSQL = "EXEC sp_start_job @job_name = '<Your DatabaseName>'"
       .Execute  strSQL
End With




0
 

Accepted Solution

by:
Retailigence earned 30 total points
Comment Utility
To Apply above code u must connect to the SQL Sever through a Connection String (AdoCON.Connectionstring= .......)
And Open it (AdoCON.Open( )). Those r normal ADO functions.
0
 

Author Comment

by:GaneshkIyer2004
Comment Utility
CREATE PROCEDURE [FPPAdmin].[Generate]
@From as numeric,
@To as numeric
 AS
Update FPPAdmin.Policydata set ReportedtoAlico =0 where serialno>=@From and serialno<=@To
EXEC msdb.dbo.sp_start_job @job_name = 'Alico New Applications'
GO

I run this procedure from VB like i run all my other procedures..But this one gives me an error..
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now