日期:2014-05-18  浏览次数:20466 次

asp.net2.0高级编程特别版中ADO.NET的异步处理一节提到的SqlAsyncResult到底哪里来的啊?网上搜索都没资料啊!程序也运行不了,郁闷!!
<%@   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   Command   =   new   SqlCommand();
                SqlAsyncResult   ASyncResult;

                DBCon   =   new   SqlConnection();
                Command   =   new   SqlCommand();
                DBCon.ConnectionString   =  
                    ConfigurationManager.ConnectionStrings[ "DSN_NorthWind "].ConnectionString;

                //   Selecting   top   5   records   from   the   Orders   table
                Command.CommandText   =  
                                "SELECT   TOP   5   Customers.CompanyName,   Customers.ContactName,   "   +
                                "Orders.OrderID,   Orders.OrderDate,   "   +
                                "Orders.RequiredDate,   Orders.ShippedDate   "   +
                                "FROM   Orders,   Customers   "   +
                                "WHERE   Orders.CustomerID   =   Customers.CustomerID   "   +
                                "ORDER   BY   Customers.CompanyName,   Customers.ContactName ";

                Command.CommandType   =   CommandType.Text;
                Command.Connection   =   DBCon;

                DBCon.Open();

                //   Starting   the   asynchronous   processing
                AsyncResult   =   Command.BeginExecuteReader(new   AsyncCallback(CBMethod),  
                      CommandBehavior.CloseConnection);
        }