扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共2页)
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class Default5 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { DateTime old = DateTime.Now; SqlConnection DbCon; SqlCommand Command = new SqlCommand(); SqlDataReader OrdersReader; IAsyncResult AsyncResult;//异步 DbCon = new SqlConnection(); DbCon.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringInfo"].ConnectionString; Command.Connection = DbCon; Command.CommandText = "Select"; Command.CommandType = CommandType.StoredProcedure; Command.Connection = DbCon; try { DbCon.Open(); AsyncResult = Command.BeginExecuteReader(); while (!AsyncResult.IsCompleted)//获取异步操作是否已完成的指示。 { //由于异步操作必须阻止线程秒钟 System.Threading.Thread.Sleep(10); } OrdersReader = Command.EndExecuteReader(AsyncResult); GridView1.DataSource = OrdersReader; GridView1.DataBind(); } catch (System.Exception) { } TimeSpan not=DateTime.Now-old; Label1.Text = not.Seconds.ToString(); } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者