Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to create a sql agent job run daily at 12 pm for example
i set this code ant its ok the job created
but how can i set the schedule ??
C#
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

ServerConnection svconn = new ServerConnection(con);
svconn.Connect();

Server server = new Server(svconn);


JobServer jobServer = server.JobServer;
Job job = null;
JobStep step = null;


// Create Job 
job = new Job(jobServer, job_Name);

job.Create();
job.ApplyToTargetServer("(local)");


// Create  db step 
if (createDB_command != "")
{
   
    step = new JobStep(job, "Creationdb_Step");
    step.Command = createDB_command;
    step.SubSystem = AgentSubSystem.TransactSql;
    step.OnSuccessAction = StepCompletionAction.GoToNextStep;
    step.Create();
}
Posted
Updated 10-Sep-14 0:22am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900