hi i need to update my database by giving timer. After every 10 sec i need to update my DB after a button click.By seeing the change in table another column(flag) should be set to ON/OFF....
please guide through this...
protected void Button1_Click(object sender, EventArgs e)
{
timer();
}
public void timer()
{
Timer = new System.Timers.Timer();
Timer.Interval = 15000;
Timer.Enabled = true;
Timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer1_Tick);
Timer.Start();
}
protected void Timer1_Tick(object sender, EventArgs e)
{
//Label1.Text = System.DateTime.Now.ToString();
SqlConnection con = new SqlConnection();
SqlCommand com1 = new SqlCommand("SELECT State,ControlId,flag,ControlValue FROM update_tr");
SqlCommand com = new SqlCommand("update update_tr SET State = 'CR' where ControlId = 'Button1'");
con.ConnectionString = "Data Source=APCOGSERVER;Initial Catalog=ApcogDB;Integrated Security=True";
con.Open();
com.Connection = con;
com1.Connection = con;
com.ExecuteReader();
com1.ExecuteReader();
SqlParameter param = new SqlParameter();
param.ParameterName="flag";
//param.ParameterName="State";
param.Value = "ON";
com1.Parameters.Add(param);
con.Close();
}