执行Sqlserver中waitfor delay延时操作或waitfor time定时操作
2016-12-19 17:18
435 查看
private static string connectionString = RBAC.Dal.DataRootBase.ConnectionString; private SqlConnection mConnection = new SqlConnection(connectionString); #region /// <summary> /// 当点击执行查询时发生(异步操作) /// 执行数据库waitfor delay延时存储过程 /// 或者waitfor time定时存储过程 /// </summary> private void Button_DoSearch_Click(object sender, EventArgs e) { SqlCommand command = new SqlCommand("pro_StoreDelay", mConnection); command.CommandType = CommandType.StoredProcedure; mConnection.Open(); AsyncCallback callBack = new AsyncCallback(HandleCallback);//注册回调方法 //开始执行异步查询,将Command作为参数传递到回调函数以便执行End操作 command.BeginExecuteReader(callBack, command); //异步查询 回调 //command.BeginExecuteNonQuery(null, command); //直接执行 无回调 } #endregion #region /// <summary> /// 异步查询的回调方法 /// </summary> /// <param name="MyResult">异步操作状态</param> private void HandleCallback(IAsyncResult MyResult) { try { //SqlCommand command = (SqlCommand)MyResult.AsyncState; //SqlDataReader reader = command.EndExecuteReader(MyResult); //DataTable dataTable = new DataTable(); //dataTable.Load(reader); //reader.Dispose(); //command.Dispose(); } catch (Exception ex) { } finally { if (mConnection != null) { mConnection.Close(); //回调后关闭连接 } } } #endregion
WAITFOR DELAY '00:00:03' --延时3秒后执行 SELECT * FROM [dbo].[AdminsBase]
相关文章推荐
- 执行Sqlserver中waitfor delay延时操作或waitfor time定时操作
- SQL - waitfor delay/time(SQL中延迟时间的方法)
- 每日20行之3~~~ThreadPool之RegisterWaitForSingleObject 自动定时执行(可循环)
- 改进的延时函数Delay(使用MsgWaitForMultipleObjects等待消息或超时的到来)
- SQL - waitfor delay/time(SQL中延迟时间的方法)
- distribution 中一直在运行 waitfor delay @strdelaytime 语句
- linux下任务的延时执行和定时执行操作及临时文件管理
- SQL - waitfor delay/time(SQL中延迟时间的方法)
- 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作(MaxUserPort,TcpTimedWaitDelay)
- sql server 中延迟时间的方法 waitfor delay / time
- Asp定时执行操作 Asp定时读取数据库(网页定时操作详解)
- Mysql定时任务(定时执行操作)
- waitfor 定时执行存储过程,触发器,T-SQL语句
- Linux下使用crontab来执行定时任务计划----执行每晚12点多执行移动log日志文件操作
- 【推荐】sqlserver里有没有定时执行sql语句更新数据库的功能?
- C# Windows 开发任务——写定时执行操作的 Windows 服务
- Asp定时执行操作 Asp定时读取数据库(网页定时操作详解)
- javascript中定时执行操作
- c#执行定时计算限制操作(计时器)
- 线程挂起和逐个执行之CreateEvent和WaitForSingleObject