zoukankan      html  css  js  c++  java
  • 执行Sqlserver中waitfor delay延时操作或waitfor time定时操作

    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


  • 相关阅读:
    three.js_ "Failed to execute 'texImage2D' on 'WebGLRenderingContext': tainted canvases may not be loded."
    three.js为何如此奇妙
    npm install ERR! code E400/E404
    小程序_请求封装network
    css_input[checked]复选框去掉默认样式并添加新样式
    【CSS】凹槽的写法
    剑指Offer_编程题_6
    剑指Offer_编程题_5
    剑指Offer_编程题_4
    剑指Offer_编程题_3
  • 原文地址:https://www.cnblogs.com/smartsmile/p/6234026.html
Copyright © 2011-2022 走看看