Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
}
Posted
Comments
CRDave1988 15-Feb-12 3:22am    
What problem u r facing? (There r many problem i think)
ZurdoDev 15-Feb-12 8:13am    
So, what's the question?

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