<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection DBCon;
SqlCommand OrdersCommand = new SqlCommand();
SqlCommand CustCommand = new SqlCommand();
SqlDataReader OrdersReader;
SqlDataReader CustReader;
IAsyncResult OrdersASyncResult;
IAsyncResult CustAsyncResult;
int WHIndex;
System.Threading.WaitHandle[] WHandles =
new System.Threading.WaitHandle[1];
System.Threading.WaitHandle OrdersWHandle;
System.Threading.WaitHandle CustWHandle;
DBCon = new SqlConnection();
DBCon.ConnectionString =
ConfigurationManager.ConnectionStrings["DSN_NorthWind"].ConnectionString;
CustCommand.CommandText =
"SELECT * FROM Customers WHERE CompanyName = 'Alfreds Futterkiste'";
CustCommand.CommandType = CommandType.Text;
CustCommand.Connection = DBCon;
OrdersCommand.CommandText =
"SELECT Customers.CompanyName, Customers.ContactName, " +
"Orders.OrderID, Orders.OrderDate, " +
"Orders.RequiredDate, Orders.ShippedDate " +
"FROM Orders, Customers " +
"WHERE Orders.CustomerID = Customers.CustomerID " +
"AND Customers.CompanyName = 'Alfreds Futterkiste' " +
"ORDER BY Customers.CompanyName, Customers.ContactName";
OrdersCommand.CommandType = CommandType.Text;
OrdersCommand.Connection = DBCon;
// Opening the database connection
DBCon.Open();
// Retrieving customer information asynchronously
CustAsyncResult = CustCommand.BeginExecuteReader();
// Retrieving orders list asynchronously
OrdersASyncResult = OrdersCommand.BeginExecuteReader();
CustWHandle = CustAsyncResult.AsyncWaitHandle;
OrdersWHandle = OrdersASyncResult.AsyncWaitHandle;
// Filling Wait Handles array with the two wait handles we
// are going to use in this code
WHandles[0] = CustWHandle;
WHandles[1] = OrdersWHandle;
// Looping 2 times because there are 2 wait handles
// in the array
for (int Index = 0; Index < 2; Index++ )
{
// We are only waiting for any of the two
// asynchronous process to finish running
WHIndex = System.Threading.WaitHandle.WaitAny(WHandles);
// The return value from the WaitAny method is
// the array index of the Wait Handle that just
// finsihed running
switch (WHIndex)
{
case 0:
CustReader = CustCommand.EndExecuteReader(CustAsyncResult);
gvCustomers.DataSource = CustReader;
gvCustomers.DataBind();
break;
case 1:
OrdersReader =
OrdersCommand.EndExecuteReader(OrdersASyncResult);
gvOrders.DataSource = OrdersReader;
gvOrders.DataBind();
break;
}
}
// Closing connection
DBCon.Close();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>The Wait Any Approach</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvCustomers" Width="100%" runat="server"></asp:GridView>
<br /><br />
<asp:GridView ID="gvOrders" Width="100%" AutoGenerateColumns="False"
runat="server">
<Columns>
<asp:BoundField HeaderText="Company Name"
DataField="CompanyName"></asp:BoundField>
<asp:BoundField HeaderText="Contact Name"
DataField="ContactName"></asp:BoundField>
<asp:BoundField HeaderText="Order Date" DataField="orderdate"
DataFormatString="{0:d}"></asp:BoundField>
<asp:BoundField HeaderText="Required Date" DataField="requireddate"
DataFormatString="{0:d}"></asp:BoundField>
<asp:BoundField HeaderText="Shipped Date" DataField="shippeddate"
DataFormatString="{0:d}"></asp:BoundField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
Professional ASP.NET 3.5全代码
共1676个文件
txt:532个
aspx:531个
cs:120个
5星 · 超过95%的资源 需积分: 9 94 下载量 62 浏览量
2008-04-12
23:05:09
上传
评论
收藏 8.05MB ZIP 举报
温馨提示
Professional ASP.NET 3.5: In C# and VB
资源推荐
资源详情
资源评论
收起资源包目录
Professional ASP.NET 3.5全代码 (1676个子文件)
Global.asax 2KB
Global.asax 1KB
Global.asax 1KB
Global.asax 1KB
Global.asax 954B
Global.asax 954B
Global.asax 954B
Global.asax 954B
Global.asax 954B
Listing26-6.ascx 811B
Listing26-9.ascx 811B
Listing26-8.ascx 811B
Listing26-7.ascx 811B
Listing26-5.ascx 811B
Listing26-4.ascx 811B
Listing26-9.ascx 707B
Listing26-6.ascx 707B
Listing26-8.ascx 707B
Listing26-7.ascx 707B
Listing26-5.ascx 707B
Listing26-4.ascx 707B
Listing26-3.ascx 616B
Listing26-3.ascx 558B
Listing26-2.ascx 226B
Listing26-2.ascx 226B
Listing26-1.ascx 99B
Listing26-1.ascx 99B
Listing27-8.ashx 445B
Listing27-7.ashx 398B
Listing 29-04.asmx 96B
Listing 29-04.asmx 96B
Listing9-4.aspx 9KB
Listing9-17.aspx 8KB
Listing9-16.aspx 8KB
Listing9-13.aspx 7KB
Listing9-3.aspx 7KB
Listing9-6.aspx 7KB
Listing9-2.aspx 7KB
Listing9-15.aspx 7KB
Listing9-9.aspx 7KB
Listing9-4.aspx 7KB
Listing9-11.aspx 7KB
Listing9-8.aspx 7KB
Listing9-10.aspx 7KB
Listing9-12.aspx 7KB
Listing9-7.aspx 7KB
Listing9-13.aspx 7KB
Listing9-17.aspx 7KB
Listing9-16.aspx 7KB
Listing9-9.aspx 7KB
Listing9-10.aspx 7KB
Listing9-8.aspx 7KB
Listing9-12.aspx 6KB
Listing9-11.aspx 6KB
Listing9-15.aspx 6KB
Listing9-3.aspx 6KB
Listing9-7.aspx 6KB
Listing9-6.aspx 6KB
Listing9-2.aspx 6KB
Listing 32-3.aspx 4KB
Listing25-6.aspx 4KB
Listing 32-3.aspx 4KB
Listing25-6.aspx 4KB
Listing25-8.aspx 4KB
Listing25-8.aspx 3KB
PatientForm.aspx 3KB
CallbackNorthwind.aspx 3KB
CallbackNorthwind.aspx 3KB
Listing25-10.aspx 3KB
Listing25-10.aspx 3KB
Listing 20-35.aspx 3KB
Listing 20-35.aspx 3KB
Listing 08-23.aspx 3KB
Listing 08-23.aspx 3KB
Listing 04-25.aspx 3KB
Listing 04-25.aspx 3KB
Listing 32-14.aspx 2KB
Listing 32-14.aspx 2KB
Listing25-3.aspx 2KB
Listing 08-10.aspx 2KB
Listing25-3.aspx 2KB
Listing 08-10.aspx 2KB
Listing 20-24.aspx 2KB
Listing 20-24.aspx 2KB
Listing25-1.aspx 2KB
Listing25-1.aspx 2KB
Listing 08-11.aspx 2KB
Listing 20-06.aspx 2KB
Listing 20-06.aspx 2KB
Listing 3-10.aspx 2KB
Listing 3-10.aspx 2KB
Listing 08-11.aspx 2KB
Listing 3-37.aspx 2KB
Listing 3-37.aspx 2KB
Listing 17-18.aspx 2KB
Listing 17-18.aspx 2KB
Listing 15-02.aspx 2KB
Listing 16-10.aspx 2KB
Listing 15-02.aspx 2KB
Listing 20-10.aspx 2KB
共 1676 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
- joeyliu2012-04-27代码可用,很好
- bigfoot1232013-07-11是原书的代码。都用过了
liminzi
- 粉丝: 13
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功