Solved

How to Run SQL Server job from VB

Posted on 2004-03-26
4
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

624 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