Solved

How to Run SQL Server job from VB

Posted on 2004-03-26
4
287 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

734 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