Solved

How to Run SQL Server job from VB

Posted on 2004-03-26
4
254 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
ID: 10702778

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
ID: 10702799
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
ID: 10703457
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to compare ms sql hashbytes results within vb6 5 76
Advice in Xamarin 21 80
Set email body to html using vbscript 6 42
Export Data to Different .csv Files 26 106
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

831 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