Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 How to run SQL Job from VB 6

Author  Topic 

alexilauren
Starting Member

3 Posts

Posted - 2005-02-02 : 16:45:33
Hi I have successfully been able to run individual DTS pack from VB6 but I am unable to figure out how to run a SQL Job (sql server agent) from VB6. I created these jobs a while ago and they consist of running many bundled DTS pack plus some other code that renames files etc. (point is I have done a lot of coding for these jobs to run, I just want to allow someone else to use VB to start the job). I would rather not recode too much as this process will only be around for about 6 more months. Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-02-02 : 16:46:42
Take a look at sp_start_job in SQL Server Books Online.

Tara
Go to Top of Page

alexilauren
Starting Member

3 Posts

Posted - 2005-02-02 : 16:54:24
Any idea what the VB code to execute the stored proc is? Thanks in advance
Go to Top of Page

alexilauren
Starting Member

3 Posts

Posted - 2005-02-02 : 16:57:24
Maybe I can used this....

Data1.Connect = "ODBC;DSN=MyDSN;" & _
";Database=MyDatabase;" & _
"Uid=sa;Pwd=;"
Data1.RecordSource = "Exec myStoredProc 5"

`This passes the SQL statement to the database
Data1.Options = Data1.Options Or dbSQLPassThrough

`Gets the results of the operations performed by the
`stored proc
Data1.Refresh

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-02-02 : 18:31:28
Whatever VB code that you use to execute stored procedure is what you would use for this.

Tara
Go to Top of Page
   

- Advertisement -