Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to Run SQL Server job from VB

Posted on 2004-03-26
4
Medium Priority
?
309 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 90 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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

721 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