I would like to have a button when pushed trigger a SQL Job run. Below is my code, for some reason I get an error message that says, "ExecuteNonQuery: Connection property has not been initialized.".
Does anyone have any suggestions?
private void btnRunDataRefresh_Click(object sender, EventArgs e)
SqlConnection cn = new SqlConnection(WindowsFormsApplication1.Properties.Settings.Default.ConnectionString);
SqlCommand ExecJob = new SqlCommand();
ExecJob.CommandType = CommandType.StoredProcedure;
ExecJob.CommandText = "msdb.dbo.sp_start_job";
Thank you in advance!