怎么样!,有人可以帮助我,请,我要找的是通过控制台应用程序每次"00“分钟(即每小时),存储过程只执行一次(我不知道为什么它运行超过1次,因为它是一个插入过程),我也希望应用程序永远不关闭,以后我想创建一个服务并执行更多的过程,但我需要一段时间。我做错了什么?,想法是在控制台中写“等待批量插入”,当时间到来时,执行过程并写“成功插入”,然后继续键入“等待批量插入”,直到下一个小时到来。
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
namespace Job_StoreProcedure
{
class Program
{
static void Main(string[] args)
{
using (SqlConnection conn = new SqlConnection
("Server=localhost\\SQLEXPRESS;Database=VIDEOJUEGOS;Integrated Security=SSPI"))
{
conn.Open();
for (int i = 0; i - 1 < i++; i++)
{
Console.WriteLine("Waiting for insertion in batch");
if (DateTime.Now.ToString("mm") == "00")
{
SqlCommand cmd = new SqlCommand("usp_virtualX", conn);
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
Console.WriteLine("Successful insertion");
}
}
}
}
}
}
}
}
https://stackoverflow.com/questions/50660484
复制相似问题