using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;
public partial class DataupDTV : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label2.Text = "Job Submitted, check your email .....";
submitjob_corpalloc();
// SqlConnection myConnection = new SqlConnection(ConnectionString);
// string strSQL;
// strSQL = "ovDTVdataupd";
// SqlCommand cmd = new SqlCommand(strSQL, myConnection);
//cmd.CommandTimeout = 0;
// cmd.CommandType = CommandType.StoredProcedure;
// myConnection.Open();
// cmd.ExecuteNonQuery();
// myConnection.Close();
// Label2.Text = "Done.....";
}
void submitjob_corpalloc()
{
SqlConnection DbConn = new SqlConnection(ConnectionString);
SqlCommand ExecJob = new SqlCommand();
ExecJob.CommandType = System.Data.CommandType.StoredProcedure;
ExecJob.CommandText = "msdb.dbo.sp_start_job";
//zzzzz@zzzzzzz.com Name Status Policy Health State
//SubmitjobSQL Not running
ExecJob.Parameters.AddWithValue("@job_name", "SubmitjobSQL");
ExecJob.Connection = DbConn; //assign the connection to the command.
using (DbConn)
{
DbConn.Open();
using (ExecJob)
{
ExecJob.ExecuteNonQuery();
}
}
}
private string ConnectionString
{
get
{
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
return connectionString;
}
}
}