jeudi 31 mai 2018

How to make my application wait until the condition is met

How about, I'm a bit new to c#, I have a stored procedure that inserts data to a backup table, I wanted to do it through a job, but I have sql server express, so it's not an option, I'm looking to do an .exe(console application) and I want you to wait until a certain time for to just run stored procedure, what would be the best way to do it?

static void Main(string[] args)
    {
       using (SqlConnection conn = new SqlConnection
             ("Server=localhost\\SQLEXPRESS;Database=VIDEOJUEGOS;IntSecurity=SSPI"))
       {
                conn.Open();

                if (DateTime.Now.ToString("HH:mm")  == "11:00")
                {
                    SqlCommand cmd = new SqlCommand("usp_virtualX", conn);
                    cmd.CommandType = CommandType.StoredPro
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            Console.WriteLine();
                        }
                    }
                }
            }
        }

Aucun commentaire:

Enregistrer un commentaire