SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ToString()); string sql = "select DISTINCT id,MAX(enddate) as enddate from table1 group by id"; SqlCommand cmd = new SqlCommand(sql, con); string d1 = DateTime.Now.ToString("dd/m/yyyy"); DateTime datenow = new DateTime(); datenow = Convert.ToDateTime(d1); DateTime enddate = new DateTime(); enddate = Convert.ToDateTime(cmd.ExecuteScalar()); if (DateTime.Compare(datenow, enddate) > 0) { string sql1 = "update users set type='Suspended Users' where users.id in(select DISTINCT id from table1 where enddate ='" + enddate + "')"; SqlCommand cmd1 = new SqlCommand(sql1, con); cmd1.ExecuteNonQuery(); for (int i = 1; i < 5; i++) { int period = 1; string sql2 = "update table3 set period='" + period + "'"; SqlCommand cmd2 = new SqlCommand(sql2, con); cmd2.ExecuteNonQuery(); period++; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)