The thread runs intermittently every 3 seconds. Suppose the program is running in the background. If I want to create / update / delete data on the sql server, the datatable is updated?

using (SqlConnection cn = new SqlConnection()) { cn.ConnectionString = @"Data Source=****;Initial Catalog=***;User ID=****;Password= ***"; cn.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter("SELECT s.id as shedule_id, s.name_ru as shedule_name_ru, s.sendType as shedule_sendType, c1.cod as typsendtype , s.typPeriod, c2.cod as time_name_ru, s.metaAlg, m.cod as meta_cod, s.dt_send, s.dt_beg as shedule_dt_beg, s.dt_send_daytime as shedule_dt_send_daytime, s.dt_period_end as shedule_dt_period_end FROM Shedule s inner join ClBaseItem c1 on s.sendType=c1.id inner join ClBaseItem c2 on s.typPeriod=c2.id inner join MetaAlg m on s.metaAlg=m.id", cn)) using (DataTable dt = new DataTable()) { adapter.Fill(dt); 

What should I write to update datatable?
The program runs in the background.

 public static void one(object state) { // тут надо писать } 
  • datatable is what? Grid on the form? DataTable with global scope? Your code is not working. Even if you add the code to receive the updated data in one (moreover, you already have this code. And, I believe, there is also a code that displays the data in datatable) the update will not occur. - Alexey
  • @Alexey datatable is a data table - propro17
  • one
    Do you think it became clearer? The fact that datatable is a data table is clear as day (the name seems to hint) The question was where it is located. If you want to create / update / delete data WHERE? On server? So you have a request for incoming data comes from several tables. Which one do you go to update? What do you mean by “running in the background” and why does this way of working differ in your way from “working in normal mode”? - Alexey
  • table update shedule . - propro17
  • @Alexey When I update the table on mssql, I want it to change in the datatable . And periodically the timer checked that the change was / was not on the table - propro17

0